Files
babymonitor/plan_1_prompt.md
2026-06-24 15:30:47 +02:00

2.4 KiB

Plan 1 — Quick Wins & Low Risk

Items covered: #7 (updated_at bug), #8 (dead code), #9 (duplicate test file), #13 (unused dependency)


Context

You are working on a FastAPI backend for a baby monitor / sleep tracker app. The codebase lives under app/. The task is to make four small, isolated fixes. Each one is mechanical and carries no risk of breaking behaviour. Do them in order. After each change, re-read the file you edited to verify it looks correct before moving on.


Tasks

1. Fix the updated_at bug (app/crud.py:106-113)

The update handler in crud.py never sets updated_at after a PATCH/PUT. Find the update function and add the following line before the session is committed:

session.updated_at = datetime.utcnow()

Make sure datetime is already imported; add the import if it is not.

2. Delete dead code

The following symbols are defined but never called anywhere. Delete them entirely:

  • ensure_aware() — located in app/crud.py:7-10
  • minutes_after() — located in app/utils/time_utils.py:60-64

After deleting each one, search the entire codebase (grep -r "ensure_aware" . and grep -r "minutes_after" .) to confirm nothing imports or calls the deleted symbol. If anything does, note it and do not delete the symbol — flag it for review instead.

Also locate day_start_pattern() in app/utils/time_utils.py. It is only used internally inside get_day_night_splits() in the same file. Rename it to _day_start_pattern (leading underscore) to mark it as a private helper and remove it from any __all__ export list if present.

3. Delete the duplicate test file

tests/test_sessions_fixed.py is an exact copy of tests/test_sessions.py. Verify they are identical (or note any differences), then delete tests/test_sessions_fixed.py.

4. Remove the unused dependency

python-multipart is listed in pyproject.toml but is not used (the app has no Form parameters). Remove it:

uv remove python-multipart

If uv is not available, remove the line manually from pyproject.toml and run uv sync or the appropriate install command to update the lockfile.


Verification

Run the full test suite after all changes:

pytest

All existing tests must pass. If any test fails, fix it before declaring this plan complete. Do not move on to Plan 2 until the test suite is green.