From ee28779138c04c6b1137c9b2919ac35d66dfcf73 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 11 Sep 2020 23:52:23 -0700 Subject: [PATCH] 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. --- frontends/etiquette_flask/backend/endpoints/tag_endpoints.py | 4 ++++ frontends/etiquette_flask/templates/tags.html | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frontends/etiquette_flask/backend/endpoints/tag_endpoints.py b/frontends/etiquette_flask/backend/endpoints/tag_endpoints.py index a790d12..7261864 100644 --- a/frontends/etiquette_flask/backend/endpoints/tag_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/tag_endpoints.py @@ -95,8 +95,11 @@ def get_tags_html(specific_tag_name=None): if specific_tag is None: tags = common.P.get_root_tags() + tag_count = common.P.get_tag_count() else: 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) response = common.render_template( @@ -105,6 +108,7 @@ def get_tags_html(specific_tag_name=None): include_synonyms=include_synonyms, specific_tag=specific_tag, tags=tags, + tag_count=tag_count, ) return response diff --git a/frontends/etiquette_flask/templates/tags.html b/frontends/etiquette_flask/templates/tags.html index b65e251..bee3530 100644 --- a/frontends/etiquette_flask/templates/tags.html +++ b/frontends/etiquette_flask/templates/tags.html @@ -163,9 +163,9 @@ h2, h3 {% if tags or not specific_tag %}
{% if specific_tag %} -

{{tags|length}} Descendants

+

{{tag_count}} Descendants

{% else %} -

{{tags|length}} Tags

+

{{tag_count}} Tags

{% endif %}