DEV Community

archi-jain
archi-jain

Posted on

Day 6/100: Quick Win - Task Priorities in 1 Hour

Sometimes the best features are the simplest.

The Challenge

Add task priority levels (high/medium/low) with filtering, sorting, and statistics.

Time constraint: Only 1 hour available today.

Result: Fully implemented in 70 minutes!

Why Priorities Matter

User problem: "All my tasks look the same. Which should I do first?"

Solution: Let users mark priority levels.

Impact:

  • Focus on high priority first
  • Filter out low priority noise
  • See if too many tasks marked urgent (priority inflation)

Implementation (15 Lines of Code)

1. Add Enum

class PriorityEnum(str, Enum):
    low = "low"
    medium = "medium"
    high = "high"
Enter fullscreen mode Exit fullscreen mode

2. Add Column

priority = Column(String(10), default="medium", index=True)
Enter fullscreen mode Exit fullscreen mode

3. Update Schemas

priority: Optional[PriorityEnum] = Field(default=PriorityEnum.medium)
Enter fullscreen mode Exit fullscreen mode

4. Add Filter

if priority:
    query = query.filter(Task.priority == priority)
Enter fullscreen mode Exit fullscreen mode

5. Update Stats

"by_priority": {
    "high": tasks.filter(Task.priority == "high").count(),
    "medium": tasks.filter(Task.priority == "medium").count(),
    "low": tasks.filter(Task.priority == "low").count()
}
Enter fullscreen mode Exit fullscreen mode

Done!

Query examples:

GET /tasks?priority=high
GET /tasks?priority=high&completed=false
GET /tasks?sort_by=priority&order=desc
Enter fullscreen mode Exit fullscreen mode

Key Takeaways

✅ Enums prevent typos (no "hgh" or "medum")

✅ Defaults prevent decision fatigue

✅ Indexes make filtering fast

✅ Simple features can have big impact

Time: 1 hour

Lines changed: ~15

User value: Immediate

Sometimes less IS more!


Day 6/100 complete!

Following my journey?

📝 Blog | 🐦 Twitter | 💼 LinkedIn

100DaysOfCode #Python #FastAPI #QuickWins

Top comments (0)