-
Notifications
You must be signed in to change notification settings - Fork 14
fix: exclude DONE tasks from get tasks API #225
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
- Updated TaskRepository queries to filter out tasks with status DONE - Ensured count and list methods do not include DONE tasks - Updated related unit tests to assert correct filtering
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Summary by CodeRabbit
WalkthroughThe changes update the task retrieval and counting logic in the Changes
Sequence Diagram(s)sequenceDiagram
participant API
participant TaskRepository
participant Database
API->>TaskRepository: list()/count()/get_tasks_for_user()
TaskRepository->>Database: Query with filter (status != "DONE")
Database-->>TaskRepository: Filtered tasks (excluding DONE)
TaskRepository-->>API: Return filtered result
Estimated code review effort2 (~15 minutes) Suggested reviewers
Poem
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. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
I've completed my review and didn't find any issues... but I did find this dinosaur.
__
/ _)
.-^^^-/ /
__/ /
<__.|_|-|_|
Files scanned
File Path | Reviewed |
---|---|
todo/repositories/task_repository.py | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
todo/repositories/task_repository.py
(4 hunks)todo/tests/unit/repositories/test_task_repository.py
(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: Achintya-Chatterjee
PR: Real-Dev-Squad/todo-backend#52
File: todo/views/task.py:106-106
Timestamp: 2025-05-29T21:36:27.694Z
Learning: Issue #26 tracks the implementation of user authentication in the todo-backend project, which includes extracting user ID from request context to replace hardcoded placeholders like "system_patch_user" in todo/views/task.py.
Learnt from: Achintya-Chatterjee
PR: Real-Dev-Squad/todo-backend#52
File: todo/views/task.py:106-106
Timestamp: 2025-05-29T21:36:27.694Z
Learning: Issue #26 in the Real-Dev-Squad/todo-backend repository comprehensively tracks user authentication implementation including registration, login, JWT tokens, and making task APIs require authentication. This covers replacing hardcoded user ID placeholders like "system_patch_user" with actual user ID extraction from authenticated requests.
Learnt from: VaibhavSingh8
PR: Real-Dev-Squad/todo-backend#81
File: .github/workflows/test.yml:10-10
Timestamp: 2025-06-16T11:09:47.782Z
Learning: In the todo-backend project, tests are mandatory but may be implemented in separate PRs. The "[skip tests]" condition in the GitHub workflow is used intentionally for specific PRs rather than as a general practice that could be abused.
Learnt from: AnujChhikara
PR: Real-Dev-Squad/todo-backend#119
File: todo/repositories/task_repository.py:149-154
Timestamp: 2025-07-09T19:59:31.694Z
Learning: In the todo-backend project, per product requirements, tasks marked as deleted (isDeleted=True) should still be returned in user task queries. The get_tasks_for_user method in TaskRepository should not filter out deleted tasks, unlike typical soft deletion patterns.
todo/tests/unit/repositories/test_task_repository.py (2)
Learnt from: AnujChhikara
PR: #119
File: todo/repositories/task_repository.py:149-154
Timestamp: 2025-07-09T19:59:31.694Z
Learning: In the todo-backend project, per product requirements, tasks marked as deleted (isDeleted=True) should still be returned in user task queries. The get_tasks_for_user method in TaskRepository should not filter out deleted tasks, unlike typical soft deletion patterns.
Learnt from: AnujChhikara
PR: #75
File: todo/tests/integration/test_tasks_delete.py:20-23
Timestamp: 2025-06-08T15:58:01.548Z
Learning: In the Real-Dev-Squad/todo-backend repository, integration tests focus on API behavior (HTTP status codes, response structure) while unit tests handle verification of actual database operations and state changes. Database verification should not be added to integration tests.
todo/repositories/task_repository.py (3)
Learnt from: AnujChhikara
PR: #119
File: todo/repositories/task_repository.py:149-154
Timestamp: 2025-07-09T19:59:31.694Z
Learning: In the todo-backend project, per product requirements, tasks marked as deleted (isDeleted=True) should still be returned in user task queries. The get_tasks_for_user method in TaskRepository should not filter out deleted tasks, unlike typical soft deletion patterns.
Learnt from: VaibhavSingh8
PR: #81
File: todo/repositories/user_repository.py:47-55
Timestamp: 2025-06-16T19:35:44.948Z
Learning: The constant RepositoryErrors.USER_OPERATION_FAILED in todo/constants/messages.py is defined as "User operation failed" without any placeholder formatting like {0}.
Learnt from: Achintya-Chatterjee
PR: #52
File: todo/views/task.py:98-112
Timestamp: 2025-06-02T17:02:22.424Z
Learning: The todo-backend project uses a global exception handler that automatically handles TaskNotFoundException, BsonInvalidId, ValueError with ApiErrorResponse, and DRFValidationError. Views should avoid try-catch blocks and let exceptions bubble up to the global handler for consistent error formatting and status codes.
🧬 Code Graph Analysis (1)
todo/repositories/task_repository.py (2)
todo/constants/task.py (1)
TaskStatus
(4-9)todo/repositories/task_assignment_repository.py (1)
get_by_assignee_id
(47-64)
🔇 Additional comments (10)
todo/repositories/task_repository.py (9)
12-12
: LGTM!The TaskStatus import is correctly added to support the new DONE task filtering functionality.
25-26
: LGTM!The base filter correctly excludes DONE tasks using MongoDB's
$ne
operator with the proper enum value reference.
32-32
: LGTM!The filter correctly combines the DONE exclusion with team task filtering using the
$and
operator.
36-36
: LGTM!The filter properly combines the DONE exclusion with user task filtering using the
$and
operator.
38-38
: LGTM!The default filter correctly applies DONE task exclusion for general queries when no specific user or team is specified.
83-83
: LGTM!The team filter correctly combines DONE exclusion with team-specific task filtering.
86-88
: LGTM!The user filter correctly combines DONE exclusion with both created and assigned tasks using proper
$and
and$or
operators.
90-90
: LGTM!The default filter correctly applies DONE task exclusion for general count queries.
222-222
: LGTM!The filter correctly combines DONE task exclusion with assigned task filtering for user-specific queries.
todo/tests/unit/repositories/test_task_repository.py (1)
100-100
: LGTM!The test correctly verifies that the count method now excludes DONE tasks by asserting the proper filter is passed to
count_documents
.
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.
add DONE records as well
…fault - Exclude DONE tasks from GET /v1/tasks by default for cleaner active task view - Add ?status=DONE query parameter to specifically retrieve DONE tasks - Implement status filtering across all task endpoints: - GET /v1/tasks - general tasks with status filtering - GET /v1/tasks?profile=true - user's tasks with status filtering - GET /v1/tasks?teamId={id} - team tasks with status filtering - Fix get_tasks_for_user to include both created AND assigned tasks - Update repository layer (list, count, get_tasks_for_user) with status_filter parameter - Update service and view layers to pass status filter from query params - Update serializer to accept status query parameter - Fix all test assertions to match new method signatures
added |
return Response(data=response.model_dump(mode="json"), status=status.HTTP_200_OK) | ||
|
||
user = get_current_user_info(request) | ||
if query.validated_data["profile"]: |
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.
any reason to change this
Closing this , fix in a new PR #227 |
Date:
July 22, 2025
Developer Name: @Achintya-Chatterjee
Issue Ticket Number
DONE
tasks from GET tasks API responses #224Description
Documentation Updated?
Under Feature Flag
Database Changes
Breaking Changes
Development Tested?
Screenshots
Screenshot 1
/v1/tasksScreen.Recording.2025-07-22.at.14.21.12.mov
/v1/tasks?profile=true
Screen.Recording.2025-07-22.at.14.24.06.mov
/v1/tasks?teamId=687f5323a73f6eed0a0c4a1d
Screen.Recording.2025-07-22.at.14.38.42.mov
/v1/tasks?status=DONE
Screen.Recording.2025-07-23.at.01.28.14.mov
/v1/tasks?profile=true&status=DONE
Screen.Recording.2025-07-23.at.01.30.28.mp4
/v1/tasks?teamId=687f5323a73f6eed0a0c4a1d&status=DONE
Screen.Recording.2025-07-23.at.01.37.30.mov
Test Coverage
Screenshot 1
Additional Notes
Description by Korbit AI
What change is being made?
Exclude tasks with status "DONE" from the results of the
get tasks
API inTaskRepository
.Why are these changes being made?
Tasks marked as "DONE" should not appear in task listings to improve relevance and clarity for users. This change applies a filter to exclude "DONE" tasks from query results, ensuring only active and relevant tasks are returned in the task management views.