Skip to content

Conversation

Achintya-Chatterjee
Copy link
Member

@Achintya-Chatterjee Achintya-Chatterjee commented Jul 21, 2025

Date: July 22, 2025

Developer Name: @Achintya-Chatterjee


Issue Ticket Number

Description

  • 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

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

Screenshot 1 /v1/tasks
Screen.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 Screenshot 2025-07-22 at 14 41 32

Additional Notes

Description by Korbit AI

What change is being made?

Exclude tasks with status "DONE" from the results of the get tasks API in TaskRepository.

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.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

- 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
@Achintya-Chatterjee Achintya-Chatterjee self-assigned this Jul 21, 2025
Copy link

coderabbitai bot commented Jul 21, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Summary by CodeRabbit

  • Bug Fixes

    • Updated task queries to consistently exclude tasks marked as "DONE" from task lists and counts.
  • Tests

    • Adjusted unit tests to verify that completed tasks are properly excluded from task counts.

Walkthrough

The changes update the task retrieval and counting logic in the TaskRepository to consistently exclude tasks with the status "DONE". This exclusion is implemented through a base filter applied to relevant query methods. Corresponding unit tests are also updated to expect the new filter criteria.

Changes

File(s) Change Summary
todo/repositories/task_repository.py Added a base filter to exclude "DONE" tasks in list, count, and get_tasks_for_user methods.
todo/tests/unit/repositories/test_task_repository.py Updated test to assert that count excludes "DONE" tasks by checking the filter in the mock call.

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
Loading

Estimated code review effort

2 (~15 minutes)

Suggested reviewers

  • iamitprakash

Poem

A rabbit hops through code so neat,
Filtering tasks so users compete.
"DONE" is now out of sight,
Only active tasks in the light!
With queries refined and tests in tow,
The task list is ready—let’s go!
🐇✨


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@korbit-ai korbit-ai bot left a 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.

Loving Korbit!? Share us on LinkedIn Reddit and X

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1c45687 and fe9f2e1.

📒 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.

Hariom01010
Hariom01010 previously approved these changes Jul 22, 2025
amit-flx

This comment was marked as off-topic.

@iamitprakash iamitprakash requested a review from amit-flx July 22, 2025 13:56
Copy link
Member

@iamitprakash iamitprakash left a 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
@Achintya-Chatterjee
Copy link
Member Author

add DONE records as well

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"]:
Copy link
Member

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

@Achintya-Chatterjee
Copy link
Member Author

Closing this , fix in a new PR #227

@Achintya-Chatterjee Achintya-Chatterjee deleted the fix/exclude-DONE-tasks-tasks-API branch July 23, 2025 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: exclude DONE tasks from GET tasks API responses
4 participants