Add Todo Priorities, Deadlines & Filtering to FastAPI Backend #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements priority levels, due dates, and filtering/sorting capabilities for the Todo API, transforming it from a basic demo into a production-ready task management backend.
Features Added
🎯 Priority Levels
Todos now support three priority levels with automatic validation:
📅 Due Dates
Todos can have optional deadlines in ISO 8601 format (
YYYY-MM-DDTHH:MM:SS), enabling time-based task organization.🔍 Advanced Filtering & Sorting
The
GET /todosendpoint now supports powerful query parameters:Filtering:
completed- Filter by completion status (true/false)priority- Filter by priority level (low/medium/high)before- Show tasks due before a specific dateafter- Show tasks due after a specific dateSorting:
sort=due_date- Sort by deadline (earliest first, null values last)sort=priority- Sort by importance (high → medium → low)Combined Queries:
Example Usage
Create a High-Priority Todo with Deadline
Response:
{ "id": 1, "title": "Submit report", "description": "Monthly project update", "completed": false, "priority": "high", "due_date": "2025-10-08T17:00:00" }Filter and Sort Tasks
Implementation Details
Changes Made
main.py(34 lines added):Todomodel withpriorityanddue_datefieldsGET /todosendpointPUT /todos/{id}to support priority and due_date updatesREADME.md(53 lines added):Total: 83 lines changed across 2 files
Key Features
/docsautomatically shows all new parametersTesting
All features have been thoroughly tested:
Benefits
This enhancement enables:
Fixes
Closes #[issue_number] - Implements the complete feature specification including:
Original prompt
This section details on the original issue you should resolve
<issue_title>Feature Proposal: Todo Priorities, Deadlines & Filtering</issue_title>
<issue_description>
Feature Proposal: Todo Priorities, Deadlines & Filtering
Labels:
enhancementfeaturebackendfrontendapiMilestone:
v0.2(proposed)Summary
Add priority levels, due dates, and filtering/sorting capabilities to the existing FastAPI Todo backend. This will turn the demo into a more realistic, production-ready task tracker where users can manage importance and deadlines effectively.
Why
Currently, each todo item only supports
title,description, andcompleted. Adding deadlines and priorities allows:Task organization by urgency.
Improved API demonstrations with query parameters.
Easier extension into a frontend or team dashboard.
<h2 style="font-style: normal; font-variant-caps: normal; letter-spacing: normal; ...
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.