Skip to content

Commit

Permalink
fix annotation counts rather than filtering multiply
Browse files Browse the repository at this point in the history
  • Loading branch information
goose-life committed Feb 3, 2025
1 parent 148fcb7 commit d75e64b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions indigo_app/forms/works.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,8 +1412,8 @@ def facet_taxonomy(self, taxonomy_tree, qs):
qs = self.filter_queryset(qs, exclude="taxonomy_topic")
# count works per taxonomy topic
counts = {
x: qs.filter(taxonomy_topics__slug=x).count()
for x in qs.only("taxonomy_topics__slug").values_list("taxonomy_topics__slug", flat=True).order_by()
x["taxonomy_topics__slug"]: x["count"]
for x in qs.values("taxonomy_topics__slug").annotate(count=Count("pk", distinct=True)).order_by().values("taxonomy_topics__slug", "count")
}

# fold the counts into the taxonomy tree
Expand Down

0 comments on commit d75e64b

Please sign in to comment.