Skip to content

feat: add optional completed filter to GET /tasks/ endpoint#19

Merged
Navashub merged 1 commit into
Navashub:mainfrom
de9pk:feature/filter-tasks-by-completed
Jun 30, 2026
Merged

feat: add optional completed filter to GET /tasks/ endpoint#19
Navashub merged 1 commit into
Navashub:mainfrom
de9pk:feature/filter-tasks-by-completed

Conversation

@de9pk

@de9pk de9pk commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR implements Issue #3 — adds an optional completed query parameter to GET /tasks/ to filter tasks by their completion status.

Changes

crud.py

  • Added from typing import Optional import
  • Updated get_tasks() to accept an optional completed: Optional[bool] = None parameter
  • When completed is provided, the query filters tasks where Task.completed == completed

routers/tasks.py

  • Added Optional to imports
  • Added completed: Optional[bool] = None query parameter to the GET /tasks/ endpoint
  • Passes the completed value to crud.get_tasks()

Usage

# Get all tasks
GET /tasks/

# Get only completed tasks
GET /tasks/?completed=true

# Get only incomplete tasks
GET /tasks/?completed=false

Closes #3

- Add optional `completed` query param to the GET /tasks/ route
- Update `get_tasks` CRUD function to filter by completion status
- Closes Navashub#3
@Navashub

Copy link
Copy Markdown
Owner

Great work @de9pk - this is a clean, focused PR that hits every requirement in Issue #3. The implementation correctly handles all three cases (completed=true, completed=false, no param), the filter composes correctly with the existing pagination, and I appreciate that you kept the query object pattern (query = db.query(...) then conditionally filter) rather than duplicating code. Branch name, commit prefix, and closing the issue via Closes #3 in the description - all done right. Merging now.

@Navashub Navashub merged commit 9c75231 into Navashub:main Jun 30, 2026
1 check passed
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.

Filter tasks by completed status via query param

2 participants