-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[WEB-4129] fix: work item filter #7698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughReworked issue queryset annotations in apps/api/plane/utils/grouper.py to use Subquery/OuterRef for assignee_ids, label_ids, and module_ids with Coalesce defaults. Updated imports accordingly. Replaced prior ArrayAgg-based defaults with an explicit loop that skips fields used for group_by or sub_group_by. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant Grouper as issue_queryset_grouper
participant ORM as Django ORM
participant DB as Database
Client->>Grouper: Request grouped issues
Grouper->>ORM: Build QuerySet with Subquery/OuterRef annotations
ORM->>DB: Execute main query + subqueries (assignees, labels, modules)
DB-->>ORM: Result rows with annotated arrays (Coalesce defaults)
ORM-->>Grouper: Annotated QuerySet
Grouper-->>Client: Grouped issues response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Pull Request Linked with Plane Work Items
Comment Automatically Generated by Plane |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (2)
apps/api/plane/utils/grouper.py (2)
51-51: Deterministic array ordering (optional).If consumers compare arrays or serialize them for tests, add ordering to ArrayAgg to keep results stable.
- .annotate(arr=ArrayAgg("assignee_id", distinct=True)) + .annotate(arr=ArrayAgg("assignee_id", distinct=True, ordering=("assignee_id",)))- .annotate(arr=ArrayAgg("module_id", distinct=True)) + .annotate(arr=ArrayAgg("module_id", distinct=True, ordering=("module_id",)))- .annotate(arr=ArrayAgg("label_id", distinct=True)) + .annotate(arr=ArrayAgg("label_id", distinct=True, ordering=("label_id",)))Also applies to: 63-63, 69-69
73-83: Fix the typing of annotations_map.The values are Django expressions, not Tuple[str, Q]. This misleads type checkers.
- annotations_map: Dict[str, Tuple[str, Q]] = { + annotations_map: Dict[str, Any] = {Optional: DRY the empty array literal with a local constant to reduce repetition.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
apps/api/plane/utils/grouper.py(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/api/plane/utils/grouper.py (2)
apps/api/plane/db/models/issue.py (2)
IssueAssignee(347-372)IssueLabel(532-547)apps/api/plane/db/models/module.py (1)
ModuleIssue(154-177)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
apps/api/plane/utils/grouper.py (4)
4-4: LGTM on ORM imports.Adding OuterRef/Subquery is appropriate for decoupling the aggregations from GROUP BY joins.
17-19: Model imports look correct.Directly referencing IssueAssignee/ModuleIssue/IssueLabel avoids brittle reverse-name paths.
36-39: Align module archived filter between grouping and annotations.You exclude archived modules in module_ids, but not when grouping by issue_module__module_id. This can surface archived groups that won’t appear in module_ids, causing inconsistent UI.
- "issue_module__module_id": Q(issue_module__deleted_at__isnull=True), + "issue_module__module_id": Q( + issue_module__deleted_at__isnull=True, + issue_module__module__archived_at__isnull=True, + ),Confirm whether archived modules should be excluded from grouping; if not, drop the archived filter from the subquery instead for consistency.
85-91: Be defensive about group_by keys format.If upstream ever passes "assignee_ids" instead of "assignees__id", the skip won’t trigger. Guard for both.
- if FIELD_MAPPER.get(key) in {group_by, sub_group_by}: + if FIELD_MAPPER.get(key) in {group_by, sub_group_by} or key in {group_by, sub_group_by}: continuePlease confirm the canonical values of group_by/sub_group_by across callers.
Description
This PR will resolve the issue where only selected assignees, modules, and labels are displayed on the work items list during filtering.
Type of Change
Summary by CodeRabbit
Bug Fixes
Performance