-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Issue Description
Enhance the existing GET v1/tasks/
API endpoint to include functionality for sorting the returned list of tasks based on multiple criteria as specified in the PRD: priority, due date, created date, and assignee. Users should also be able to specify the sort order (ascending or descending).
- PRD: https://docs.google.com/document/d/1KOFK8ISE1hy9h8QjNbrObo6QKeM1I-rYZTJ8ygwfxhg/edit?usp=sharing
- Design Doc: https://docs.google.com/document/d/1SyC7j7VCZn18xjOM5dBI1BuE8GE0cBakEFFWp-Np_qQ/edit?usp=sharing
Expected Behaviour
When new sorting query parameters are added to the GET /tasks/ request:
- Sort Field (?sort_by=):
- Supports values:
priority
,due_date
,created_date
,assignee
.
- Sort Order (?order=):
- Supports values:
asc
(ascending),desc
(descending). - If
order
is not provided, a sensible default should be used (e.g.,desc
forcreated_date
,asc
fordue_date
).
- The API should return the list of tasks sorted according to the specified field and order.
- If
sort_by
is not provided, a default sort order should apply (e.g., bycreated_date
descending). - The sorting should work in conjunction with existing pagination and any implemented search/filtering capabilities.
- If invalid
sort_by
ororder
parameters are provided, the API should handle it gracefully:
- Return a 400 Bad Request error with the appropriate error details.
Current Behaviour
Currently:
- The GET
v1/tasks/
API may have a default sort order (e.g., by creation date or ID). - It does not support user-specified sorting based on the PRD criteria (priority, due date, created date, assignee) or custom sort order.
Screenshots
- Flow Diagram
Reproducibility
- This issue is reproducible
- This issue is not reproducible
Steps to Reproduce
- Attempt to call GET 1v1/tasks/?sort_by=priority&order=asc`.
- Observe that the API does not sort the tasks according to these parameters (or returns an error if parameters are strictly validated and unknown ones are rejected).
Severity/Priority
- Critical
- High (Essential for task assignment functionality as per PRD)
- Medium
- Low
Additional Information
-
Define default sorting if no parameters are provided.
-
Clarify how
priority
sorting should work (e.g., based on a numerical value or predefined order like high > medium > low). -
This enhancement will require updates to the
TaskService.get_tasks
method and the repository layer to apply the sorting to the database query. -
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.