Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions app/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ def list_tasks(status: str | None = None, q: str | None = None) -> list[dict[str
for task in tasks:
# Instructor note: intentional bug for the lab.
# This uses the literal string "status" instead of the query parameter value.
if status and task["status"] != "status":
if status and task["status"] != status:
continue

# Instructor note: partial feature for the lab.
# The route already accepts `q`, but search is not implemented yet.
if q:
query = q.lower()
title = task.get("title", "").lower()
description = task.get("description", "").lower()
if query not in title and query not in description:
continue

filtered.append(task)

return filtered
Expand Down Expand Up @@ -53,12 +60,12 @@ def complete_task(task_id: int) -> dict[str, Any] | None:

for task in tasks:
if task["id"] == task_id:
updated_task = dict(task)
updated_task["status"] = "done"
updated_task["completed_at"] = datetime.now(timezone.utc).isoformat()
task["status"] = "done"
task["completed_at"] = datetime.now(timezone.utc).isoformat()
save_tasks(tasks)

# Instructor note: intentional bug for the lab.
# The updated task is returned, but the stored list is never updated or saved.
return updated_task
return task

return None
6 changes: 3 additions & 3 deletions data/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"id": 3,
"title": "Plan workshop agenda",
"description": "Outline topics for the partner onboarding session.",
"status": "open",
"status": "done",
"priority": "medium",
"created_at": "2026-02-27T11:45:00+00:00",
"completed_at": null
"completed_at": "2026-07-21T14:00:31.277346+00:00"
},
{
"id": 4,
Expand All @@ -35,4 +35,4 @@
"created_at": "2026-03-01T08:20:00+00:00",
"completed_at": null
}
]
]