Skip to content

Feat: Enhance GET v1/tasks/ API to support sorting by priority, due_date, created_date, and assignee #64

@Achintya-Chatterjee

Description

@Achintya-Chatterjee

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

Expected Behaviour

When new sorting query parameters are added to the GET /tasks/ request:

  1. Sort Field (?sort_by=):
  • Supports values: priority, due_date, created_date, assignee.
  1. Sort Order (?order=):
  • Supports values: asc (ascending), desc (descending).
  • If order is not provided, a sensible default should be used (e.g., desc for created_date, asc for due_date).
  1. The API should return the list of tasks sorted according to the specified field and order.
  2. If sort_by is not provided, a default sort order should apply (e.g., by created_date descending).
  3. The sorting should work in conjunction with existing pagination and any implemented search/filtering capabilities.
  4. If invalid sort_by or order parameters are provided, the API should handle it gracefully:
  • Return a 400 Bad Request error with the appropriate error details.

Current Behaviour

Currently:

  1. The GET v1/tasks/ API may have a default sort order (e.g., by creation date or ID).
  2. 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

Image

Reproducibility

  • This issue is reproducible
  • This issue is not reproducible

Steps to Reproduce

  1. Attempt to call GET 1v1/tasks/?sort_by=priority&order=asc`.
  2. 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.

Metadata

Metadata

Labels

feature taskA big ticket item that needs to come up as a feature

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions