Pass separate tag_count into tags.html to prevent double-counting.

Foolishly, I was checking the length of the outputted easybake format,
which included lines for synonyms and multi-parent tags that shouldn't
be part of the tag count.
master
voussoir 2020-09-11 23:52:23 -07:00
parent 2a9b2cd095
commit ee28779138
2 changed files with 6 additions and 2 deletions

View File

@ -95,8 +95,11 @@ def get_tags_html(specific_tag_name=None):
if specific_tag is None: if specific_tag is None:
tags = common.P.get_root_tags() tags = common.P.get_root_tags()
tag_count = common.P.get_tag_count()
else: else:
tags = [specific_tag] tags = [specific_tag]
tag_count = sum(1 for child in specific_tag.walk_children())
tags = etiquette.tag_export.easybake(tags, include_synonyms=False, with_objects=True) tags = etiquette.tag_export.easybake(tags, include_synonyms=False, with_objects=True)
response = common.render_template( response = common.render_template(
@ -105,6 +108,7 @@ def get_tags_html(specific_tag_name=None):
include_synonyms=include_synonyms, include_synonyms=include_synonyms,
specific_tag=specific_tag, specific_tag=specific_tag,
tags=tags, tags=tags,
tag_count=tag_count,
) )
return response return response

View File

@ -163,9 +163,9 @@ h2, h3
{% if tags or not specific_tag %} {% if tags or not specific_tag %}
<div id="hierarchy_tags"> <div id="hierarchy_tags">
{% if specific_tag %} {% if specific_tag %}
<h3>{{tags|length}} Descendants</h3> <h3>{{tag_count}} Descendants</h3>
{% else %} {% else %}
<h2>{{tags|length}} Tags</h2> <h2>{{tag_count}} Tags</h2>
{% endif %} {% endif %}
<ul id="tag_list"> <ul id="tag_list">
{% for (qualified_name, tag) in tags %} {% for (qualified_name, tag) in tags %}