Skip to content

Conversation

@amit-flx
Copy link
Contributor

@amit-flx amit-flx commented Jul 16, 2025

Description by Korbit AI

What change is being made?

Add teamId as a query filter for task retrieval and update related logic in the task repository, serializers, and views to support filtering tasks assigned to teams.

Why are these changes being made?

These changes enable users to filter tasks by a specific team, enhancing the task management functionality to accommodate team-based task assignments. This approach efficiently integrates the team filtering logic within existing methods, providing a streamlined solution without altering fundamental task retrieval operations.

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

- Introduced a new query parameter `teamId` to filter tasks assigned to a specific team.
- Updated the `TaskRepository` methods to support filtering by `teamId` in both task listing and counting.
- Enhanced the `GetTaskQueryParamsSerializer` to include `teamId` as an optional field.
- Modified the `TaskService` and `TaskListView` to handle the new `teamId` parameter in task retrieval requests.
- Updated OpenAPI documentation to reflect the new filtering capability for tasks.
@coderabbitai
Copy link

coderabbitai bot commented Jul 16, 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

  • New Features

    • Added support for filtering tasks by team using an optional team ID parameter in the tasks list endpoint.
  • Bug Fixes

    • Updated integration tests to accommodate the new team filtering parameter.

Walkthrough

A new optional query parameter, teamId, was introduced to the GET /v1/tasks endpoint to enable filtering tasks by team assignment. This required changes to the API schema, serializers, view logic, service, repository, and related integration tests to support and propagate the teamId parameter throughout the stack.

Changes

File(s) Change Summary
schema.yaml Added optional teamId query parameter to GET /v1/tasks endpoint for team-based task filtering.
todo/serializers/get_tasks_serializer.py Added optional teamId field to GetTaskQueryParamsSerializer.
todo/views/task.py Updated TaskListView to extract and pass teamId to service layer.
todo/services/task_service.py Modified get_tasks to accept and forward optional team_id to repository methods.
todo/repositories/task_repository.py Updated list and count methods to accept team_id and filter tasks by team when provided.
todo/tests/integration/test_task_sorting_integration.py Adjusted mocked method assertions to include new team_id parameter in test calls.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant TaskListView
    participant GetTaskQueryParamsSerializer
    participant TaskService
    participant TaskRepository

    Client->>TaskListView: GET /v1/tasks?teamId=TEAM123
    TaskListView->>GetTaskQueryParamsSerializer: Validate query params (teamId)
    TaskListView->>TaskService: get_tasks(..., team_id=TEAM123)
    TaskService->>TaskRepository: list(..., team_id=TEAM123)
    TaskRepository-->>TaskService: Filtered tasks by team
    TaskService-->>TaskListView: Filtered tasks
    TaskListView-->>Client: Response with filtered tasks
Loading

Poem

A new path for tasks is here,
With teams in mind, the way is clear.
Filter by teamId, swift and neat,
Rabbits hop—no need to repeat!
Through code and tests, the journey's done,
Now teamwork shines for everyone.
🐇✨


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.

- Reformatted the `list` method signature in `TaskRepository` for better readability by breaking it into multiple lines.
- Ensured consistent spacing and organization of import statements within the method.
- Modified assertions in the `TaskSortingIntegrationTest` to include a `None` parameter in the `mock_list` calls for various sorting scenarios.
- Ensured consistency in the test cases by aligning the method calls with the updated signature of the `list` method in `TaskRepository`.
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.

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Functionality Incomplete Team Task Filtering ▹ view
Design Duplicate Team Task Filtering Logic ▹ view
Files scanned
File Path Reviewed
todo/serializers/get_tasks_serializer.py
todo/repositories/task_repository.py
todo/views/task.py
todo/services/task_service.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

Comment on lines +25 to +26
team_task_ids = [assignment.task_id for assignment in team_assignments]
query_filter = {"_id": {"$in": team_task_ids}}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete Team Task Filtering category Functionality

Tell me more
What is the issue?

The team filter doesn't consider tasks created by team members, only tasks assigned to the team.

Why this matters

Team members won't see tasks that were created by their teammates but not explicitly assigned to the team, potentially missing important team-related tasks.

Suggested change ∙ Feature Preview

Modify the team filtering logic to include tasks created by team members:

from todo.repositories.team_repository import UserTeamDetailsRepository

# Get team members
team_members = UserTeamDetailsRepository.get_by_team_id(team_id)
team_member_ids = [str(member.user_id) for member in team_members]

query_filter = {"$or": [
    {"_id": {"$in": team_task_ids}},
    {"createdBy": {"$in": team_member_ids}}
]}
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

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: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10f31a8 and cc3dc6e.

📒 Files selected for processing (6)
  • schema.yaml (1 hunks)
  • todo/repositories/task_repository.py (2 hunks)
  • todo/serializers/get_tasks_serializer.py (1 hunks)
  • todo/services/task_service.py (1 hunks)
  • todo/tests/integration/test_task_sorting_integration.py (6 hunks)
  • todo/views/task.py (2 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 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 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: 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: 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.
Learnt from: shobhan-sundar-goutam
PR: Real-Dev-Squad/todo-backend#95
File: todo/services/label_service.py:86-91
Timestamp: 2025-07-02T18:44:05.550Z
Learning: In the Real-Dev-Squad/todo-backend project, the GET v1/labels endpoint is designed to return only three fields in the response: id, name, and color. The prepare_label_dto method in todo/services/label_service.py intentionally excludes other LabelDTO fields like createdAt, updatedAt, createdBy, and updatedBy from the API response.
todo/serializers/get_tasks_serializer.py (1)
Learnt from: shobhan-sundar-goutam
PR: Real-Dev-Squad/todo-backend#95
File: todo/views/label.py:21-21
Timestamp: 2025-07-02T18:28:01.803Z
Learning: In Django REST Framework serializers, when a CharField has default="" specified, the validated_data will always contain a string value (empty string if parameter not provided) rather than None, making None-checks unnecessary when accessing that field from validated_data.
todo/views/task.py (1)
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/integration/test_task_sorting_integration.py (2)
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.
Learnt from: VaibhavSingh8
PR: Real-Dev-Squad/todo-backend#83
File: todo/tests/unit/services/test_user_service.py:37-43
Timestamp: 2025-06-17T18:59:14.368Z
Learning: UserRepository.create_or_update is a static method in the todo application, so it should be mocked directly on the class rather than on an instance.
todo/services/task_service.py (1)
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/repositories/task_repository.py (1)
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.
🧬 Code Graph Analysis (1)
todo/repositories/task_repository.py (3)
todo/models/task.py (1)
  • TaskModel (23-43)
todo/repositories/common/mongo_repository.py (1)
  • get_collection (17-20)
todo/repositories/assignee_task_details_repository.py (2)
  • AssigneeTaskDetailsRepository (9-107)
  • get_by_assignee_id (41-52)
🪛 GitHub Actions: Tests
todo/tests/integration/test_task_sorting_integration.py

[error] 52-52: AssertionError: expected call not found. Expected call missing None argument, actual call has 'team_id=None'.


[error] 106-106: AssertionError: expected call not found. Expected call missing None argument, actual call has 'team_id=None'.


[error] 39-39: AssertionError: expected call not found. Expected call missing None argument, actual call has 'team_id=None'.


[error] 75-75: AssertionError: expected call not found for sort_field='createdAt'. Expected call missing None argument, actual call has 'team_id=None'.


[error] 75-75: AssertionError: expected call not found for sort_field='dueAt'. Expected call missing None argument, actual call has 'team_id=None'.


[error] 75-75: AssertionError: expected call not found for sort_field='priority'. Expected call missing None argument, actual call has 'team_id=None'.


[error] 75-75: AssertionError: expected call not found for sort_field='assignee'. Expected call missing None argument, actual call has 'team_id=None'.


[error] 87-87: AssertionError: expected call not found. Expected call missing None argument, actual call has 'team_id=None'.


[error] 27-27: AssertionError: expected call not found. Expected call missing None argument, actual call has 'team_id=None'.

🔇 Additional comments (9)
schema.yaml (1)

411-415: LGTM: Well-documented API parameter addition

The teamId query parameter is properly defined with clear documentation and correct typing. The optional nature aligns with the filtering use case.

todo/serializers/get_tasks_serializer.py (1)

38-38: LGTM: Proper serializer field configuration

The teamId field is correctly configured as optional with appropriate validation rules. The allow_blank=False and allow_null=True settings are suitable for this filtering parameter.

todo/views/task.py (2)

48-54: LGTM: Consistent API documentation

The OpenAPI parameter documentation follows the same pattern as other query parameters and provides clear information about the filtering capability.


91-91: LGTM: Proper parameter extraction and forwarding

The teamId parameter is correctly extracted from validated data and passed to the service layer, following the established pattern for other parameters.

Also applies to: 98-98

todo/services/task_service.py (2)

62-62: LGTM: Well-designed parameter addition

The team_id parameter is added with a sensible default value of None, maintaining backward compatibility while enabling the new filtering functionality.


67-68: LGTM: Consistent parameter forwarding

The team_id parameter is correctly passed to both repository methods using keyword arguments, maintaining consistency with the existing codebase pattern.

todo/repositories/task_repository.py (3)

18-20: Method signature updated correctly to support team filtering.

The addition of the team_id parameter with a default value of None maintains backward compatibility while enabling the new team-based filtering functionality.


71-71: Method signature updated correctly for consistency.

The count method signature change matches the list method, maintaining consistency in the repository interface.


73-79: Team filtering logic in count method mirrors list method correctly.

The implementation correctly duplicates the team filtering logic from the list method, ensuring consistent behavior between counting and listing operations. The query filter construction is identical, which is appropriate.

… assertions

- Adjusted assertions in `TaskServiceTests` and `TaskServiceSortingTests` to include a `None` parameter in the `mock_list` calls, ensuring alignment with the updated method signature.
- Enhanced test coverage for task retrieval scenarios by reflecting the latest changes in the `TaskRepository` interface.
- Modified assertions in various test files, including `TaskSortingIntegrationTest`, `TaskPaginationIntegrationTest`, `TaskServiceTests`, and `TaskViewTests`, to include `team_id=None` in the `mock_list` and `mock_get_tasks` calls.
- Ensured consistency across tests by aligning with the updated method signatures that now require the `team_id` parameter for task retrieval.
…k view tests

- Reformatted the `mock_get_tasks` call in `TaskViewSortingTests` to enhance readability by breaking parameters into multiple lines.
- Ensured consistency with previous updates that included the `team_id` parameter in task retrieval assertions.
@iamitprakash iamitprakash merged commit ea5eb09 into RealDevSquad:develop Jul 16, 2025
2 checks passed
@amit-flx amit-flx deleted the get-team-task branch July 24, 2025 09:12
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.

2 participants