Repository navigation
feat: save recommendation snapshots per night (#95) - #118
Merged
Merged
Conversation
With no room_type_id, snapshot_recommendations priced every room type and one the active model wasn't trained on raised a 422, so nothing was saved. Only the room types the model was trained on are priced now; naming an untrained one still raises.
selvarajuv
force-pushed
the
95-recommendation-snapshot
branch
from
October 27, 2026 18:20
dec963e to
fc9c86c
Compare
selvarajuv
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Save each night's recommended rate with its model, range and factors,
and read back a night's latest and previous rate. A night is only
saved again when its model, rate or range changed (decision 0032).
A pricing model with snapshots can't be deleted, so past rates stay.
Type of change
feat— new featurefix— bug fixdocs— documentation onlyrefactor— code change that neither fixes a bug nor adds a featureperf— performance improvementtest— adding or updating testschore/build/ci— tooling, deps, or pipeline changesChanges
API
POST /hotels/{id}/recommendations/snapshots?days=30[&room_type_id=]: prices each night from today (1–90 nights, every room type unless one is given) and saves the rates that changed. Returns only the snapshots saved.GET /hotels/{id}/recommendations/snapshot?date=[&room_type_id=]: a night's latest and previous snapshot, pluschange(latest minus previous, in €). A future night with no snapshot is priced and saved now; a past night with none is a 404.GET /hotels/{id}/recommendationsis unchanged. It still saves nothing and works as a preview.Model / database
recommendation_snapshotstable: hotel, room type, stay date, model id and version, rate, interval low/high, uncertainty, factors (JSONB), created at. The migration upgrades and downgrades cleanly.model_idisON DELETE NO ACTION: a pricing model with snapshots can't be deleted, so past rates stay as they were. Deleting a hotel still removes its snapshots.Business logic
Docs and tests
docs/system-design.mdis updated (table, routes, foreign-key rule, scheduling note).backend/tests/test_recommendation_snapshots.py.Database migrations
just migrate-create "...")just migrate) and rolls back (just migrate-down)Checklist
just lint) and code is formatted (just format)just hooksinstalled).env.examplewhere relevantjust dev) and verified the API athttp://localhost:8000/docsHow to test
Notes for reviewers