List orders needing attention

Python · FastAPI · intermediate · greenfield

Adds the attention-list endpoint: filters orders down to the ones that need attention and returns them newest first. Matches the sample data.

Requirements

Files touched

--- app/routes/attention.py
+from fastapi import APIRouter
+from app.orders import all_orders
+
+router = APIRouter()
+
+
[email protected]("/orders/attention")
+async def orders_needing_attention():
+    orders = [
+        o
+        for o in all_orders()
+        if o.status in ("pending", "failed") and not o.cancelled
+    ]
+    return sorted(orders, key=lambda o: o.created_at)

Review this PR

Python practice