Repository navigation
feat(jobs): report when each kind of data was last refreshed - #119
Open
heatherlarange wants to merge 3 commits into
Open
heatherlarange wants to merge 3 commits into
heatherlarange wants to merge 3 commits into
Conversation
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
Adds
GET /hotels/{id}/freshness, which says when each kind of data was lastsuccessfully updated for a hotel, whether the latest attempt failed, and whether
the data is stale. The manager can then see when rates may be out of date,
and the frontend doesn't need to know the staleness.
Closes #101
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
GET /hotels/{id}/freshness(routes/freshness.py). For each ofevents,weather,hotel_data, andtraining, it returnslast_success,last_failure(only when the latest attempt failed or stopped),errorandstale. An unknown hotel is a 404.services/domain/freshness.pyholds the rules in one table(
KINDS):mode: "recent") and weather(
mode: "forecast"); backfills don't make upcoming rates fresh.days. Never succeeding is stale.
latest_finished_jobinrepository/job.py, the newestfinished job of a kind, optionally filtered by status. The second query
(for the last success) only runs when the latest attempt failed.
design file layout and API table.
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
just test: the 7 tests intests/test_freshness.pycover never run,succeeded, failed after a success, failed and never succeeded, a success
clearing an earlier failure, succeeded but stale, and a backfill not
counting as a refresh.
just dev, create a city and hotel, then callGET /hotels/{id}/freshness: every kind showsnulltimes andstale: true.POST /hotels/{id}/ingest/weatherwith{}. Once the job succeeds,weathershows alast_successandstale: false.GET /hotels/999999/freshnessreturns 404.Notes for reviewers
recommendationsis alwaysnull. When they are stored, it gets one row inKINDS.Only "events older than a day" came from the ticket.
GET /hotels/{id}/jobs.failed, stale, and a backfill not counting). All four kinds go through the
same code; only their row in
KINDSdiffers.