Fix Focus Queue filter counts stuck at 0 or 1 - #403
Merged
Conversation
_task_types_with_counts() aggregated over a queryset that still carried
its display .order_by("due_today_rank", "priority_rank", "created_at").
Django folds those columns into the implicit GROUP BY once .values()
.annotate() follows, so groups split on created_at/rank instead of just
task_type — collapsing every pill count to 0 or 1. Clear the inherited
ordering with .order_by() before aggregating.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DqEbdJPKgXjFrYGAWByQD8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/focusfilter pill counts were showing 0 or 1 for every task type instead of the real count_task_types_with_counts()aggregated (.values().annotate(Count(...))) over a queryset that still carried its display.order_by("due_today_rank", "priority_rank", "created_at"); Django folds those order-by columns into the implicitGROUP BY, splitting eachtask_typegroup down to near-unique rows.order_by()before aggregatingTest plan
test_task_type_counts_unaffected_by_active_filterto create two tasks of the same type (previous version only created one per type, so it couldn't distinguish correct behavior from the bug)1 != 2) and passes with the fix./dev.py test my_practice.tests.test_views_focus_queue my_practice.tests.test_sync_focus_queue_tasks my_practice.tests.test_weekly_focus_widget— all pass🤖 Generated with Claude Code
https://claude.ai/code/session_01DqEbdJPKgXjFrYGAWByQD8