generated from RealDevSquad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
enhancementImproving something existingImproving something existingfeature taskA big ticket item that needs to come up as a featureA big ticket item that needs to come up as a featurepythonPull requests that update python codePull requests that update python code
Description
Issue Description
The current GET /tasks endpoint does not support filtering tasks by assignee. To support the new frontend requirement of filtering the team todo list by one or multiple assignees, the backend needs to be updated to accept and process assignee-based filtering parameters.
Expected Behaviour
- The
GET /tasksendpoint should accept a new query parameter, e.g.,assigneeId(which can be repeated for multiple values, e.g.,?assigneeId=123&assigneeId=456). - The
TaskListViewintodo/views/task.pyshould parse this parameter. - The
TaskService.get_tasksmethod should accept this list of assignee IDs. - The
TaskRepository.listmethod should filter the returned tasks to include only those where the assignee matches one of the provided IDs. - Database Context: The application uses a dual-write system (
MongoDB + PostgreSQL), but reads are exclusively performed againstMongoDB(TaskRepository). The new filtering logic must be implemented inTaskRepository(MongoDB) to maintain consistency. - Sorting Context: Sorting is already implemented in
TaskRepository.listfor fields likepriorityandupdatedAt. Assignee sorting is currently disabled (SORT_FIELD_ASSIGNEE), which is acceptable as the requirement is only for filtering. - Since assignees are stored in the
task_assignmentscollection, the repository logic needs to query this collection to find matching task IDs, or we should use an aggregation pipeline to filter effectively. - The filter should work in combination with existing filters like
teamIdandstatus.
Current Behaviour
- The
TaskListView(todo/views/task.py) acceptsteamId,status,page,limit,sort_by, andorder. - The
TaskRepository.list(todo/repositories/task_repository.py) builds aMongoDBquery based on these parameters. - There is no logic to handle
assigneeIdfiltering. TaskRepositoryhas a helper_get_assigned_task_ids_for_userwhich gets tasks for a specific user (the requester), but this is for permission/visibility, not for an arbitrary filter.
Screenshots
N/A
Reproducibility
- This issue is reproducible
- This issue is not reproducible
Steps to Reproduce
- Send a `GET` request to `/tasks?assigneeId=`.
- Observe that the `assigneeId` parameter is ignored, and tasks are not filtered by the assignee.
- [] Critical
- High
- Medium
- Low
Additional Information
- Files to modify:
todo/views/task.py: UpdateTaskListViewandextend_schemaparameters.todo/services/task_service.py: Updateget_taskssignature and logic.todo/repositories/task_repository.py: Updatelistandcountmethods.- Since
TaskAssignmentRepositoryholds the mapping, we might need to first queryTaskAssignmentRepositoryfor all task IDs assigned to the providedassigneeIds(and filtered byteamIdif present). - Then, use this list of task IDs in the
$inclause of the mainTaskRepositoryquery. - We should be mindful of performance if the number of tasks is large; however, for a team's to-do list, I think it should be manageable.
Checklist
- I have read and followed the project's code of conduct.
- I have searched for similar issues before creating this one.
- I have provided all the necessary information to understand and reproduce the issue.
- I am willing to contribute to the resolution of this issue.
Metadata
Metadata
Assignees
Labels
enhancementImproving something existingImproving something existingfeature taskA big ticket item that needs to come up as a featureA big ticket item that needs to come up as a featurepythonPull requests that update python codePull requests that update python code