diff --git a/backend/app/feedquery.py b/backend/app/feedquery.py index 9fcdca4c..2703583e 100644 --- a/backend/app/feedquery.py +++ b/backend/app/feedquery.py @@ -104,6 +104,8 @@ def tags_by_category(db: Session, tag_ids: list[int]) -> dict[str, list[int]]: """Group tag ids by their category (language/topic/other). The single source for the category split shared by the feed's tag WHERE (filtered_query) and the facet/count summary (feed_summary), so the two can't disagree on which selected tag belongs to which category.""" + if not tag_ids: + return {} # skip the pointless `WHERE id IN ()` round-trip on the no-tag-filter hot path out: dict[str, list[int]] = {} for tid, cat in db.execute(select(Tag.id, Tag.category).where(Tag.id.in_(tag_ids))).all(): out.setdefault(cat, []).append(tid)