You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Save a snapshot of every night's recommendation on each run #95
GET /hotels/{id}/recommendations works out a rate and throws it away. Without a record of what we recommended and when, we can't show how a night's rate changed since the last update, tie the manager's feedback to the rate they saw, or check later how good it was.
Goal
Each time recommendations are produced, the rate for every night is saved with the model version and time, so any night's history of rates can be read back.
Scope
A recommendation_snapshots table: hotel, room type, stay date, pricing model id and version, rate, interval low and high, factor breakdown (JSONB), created at.
A service that produces and saves snapshots for a range of nights (e.g. the next 30), used by the scheduled run and on demand.
Reads return the latest snapshot for a night; if a night has none, produce and save one.
A way to get the previous snapshot for a night, to compute the change since the last update.
Models, repository and services through every layer, following the Widget slice.
An Alembic migration that applies and rolls back.
Considerations
Keep one row per night per run, not per model version: new events change a rate without a retrain, and the manager needs to see that change.
Don't save a new row when nothing changed since the last snapshot, or the table grows with identical rows; decide how "unchanged" is judged (same model version and inputs, or same rate).
Snapshots for past nights must stay as they were; they're what feedback and later checks refer to.
Acceptance criteria
Producing recommendations for a range saves one snapshot per night.
After new inputs change a night's rate, a new snapshot is saved and the previous one is kept.
The latest and previous snapshot for a night can be read.
The migration upgrades and downgrades cleanly.
Tests cover saving, reading and the change between snapshots.
Activity