feat: return unfiltered_total in project list response#40
Conversation
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Adds an `unfiltered_total` field to the project list endpoint that returns the total count of projects the user has access to, ignoring the current search and filter parameters. This allows the frontend to display context like "Showing 3 projects (filtered from 42)". Closes #34 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d0729cd to
bffa323
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ontokit/services/project_service.py (1)
476-494: Consider movingsubquerydefinition closer to its usage for clarity.The
subqueryvariable defined at line 464 is reused at lines 489 and 492. While this works correctly due to Python's function-level scoping (and both definition and usage occur only whenuser is not None), it creates an implicit coupling between distant code blocks.For improved maintainability, consider defining the subquery once at the method level (guarded by
user is not None) or inline where needed.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ontokit/services/project_service.py` around lines 476 - 494, The subquery used in the access-control block (referenced as subquery in the Project.id.in_(subquery) checks when filter_type is "private" or "mine") is defined far above its usages; move its definition so it's declared immediately before the "if user is None: ... else:" branch or inside the "else:" guard where user is not None, or alternatively hoist a single guarded definition at the top of the method under if user is not None to avoid the implicit coupling—ensure the symbol name remains subquery and that its scope covers both Project.id.in_(subquery) checks and any other access_clause construction that relies on it.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ontokit/services/project_service.py`:
- Around line 476-494: The subquery used in the access-control block (referenced
as subquery in the Project.id.in_(subquery) checks when filter_type is "private"
or "mine") is defined far above its usages; move its definition so it's declared
immediately before the "if user is None: ... else:" branch or inside the "else:"
guard where user is not None, or alternatively hoist a single guarded definition
at the top of the method under if user is not None to avoid the implicit
coupling—ensure the symbol name remains subquery and that its scope covers both
Project.id.in_(subquery) checks and any other access_clause construction that
relies on it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2ce96c14-1ed6-45b4-872d-b1c66091dd1f
📒 Files selected for processing (2)
ontokit/schemas/project.pyontokit/services/project_service.py
Summary
unfiltered_totalfield toProjectListResponseschema, representing the total count of projects accessible to the user before any search or filter params are appliedlist_accessibleinProjectServiceto compute the unfiltered count from the access-control query before applyingfilter_typeandsearchCloses #34
Test plan
GET /api/v1/projectsreturnsunfiltered_totalequal tototalwhen no filters/search are appliedunfiltered_totalstays constant when applyingfilter_type=public,filter_type=mine,filter_type=private, orsearch=...unfiltered_total(count of all public projects)unfiltered_totalis always >=total🤖 Generated with Claude Code
Summary by CodeRabbit
unfiltered_totalfield alongside the existing filtered total count. This metric displays the total number of accessible projects before any search terms or type-based filters are applied, allowing users to better understand the complete scope of available projects versus filtered results.