Skip to content

feat: refresh the catalog automatically - #641

Merged
shiny-code-bot merged 2 commits into
mainfrom
work/638-automatic-catalog-refresh
Sep 21, 2026
Merged

shiny-code-bot merged 2 commits into
mainfrom
work/638-automatic-catalog-refresh

Conversation

@shiny-code-bot

Copy link
Copy Markdown
Collaborator

Why

Catalog refresh became operator-only on 2026-07-19 (ddd0c6c1 rightly stopped page loads from starting scans) and nothing replaced the trigger. The production catalog then went two months without a refresh: Futurama Season 11 (added in August) has no library rows, so Season 10 is held as the current season. Refs #638.

What changed

  • A leader-owned catalog-refresh-worker checks once a minute (first check a minute after startup) and starts an inventory-only refresh when the last finished full refresh is older than media.catalog_refresh_hours (default 6, 0 turns it off).
  • It reuses maybe_schedule_scan, so it honours "Pause new background work", never overlaps an active scan, and re-runs a refresh that a restart interrupted. After any other failure it waits 30 minutes.
  • "Catalog is stale" now means two missed intervals (or a day when automatic refresh is off) instead of 15 minutes.
  • No read path starts a scan.

Root cause note for the scan history

All 3,407 scan_runs rows are failed because migration 20260731_0020 added status with a default of running and then marked every running row failed, including scans that had finished. Scans were not failing; the history cannot be restored because the same statement filled in completed_at. The first automatic refresh gives latest_scan_completed_at a real row.

Not in this PR (tracked in #638)

Settings UI for the interval, a missing-credentials notice, and carrying provider credentials to a new runtime checkout.

Tests

New tests for due, not due, turned off and paused; the staleness test follows the interval; the worker-start test covers the new worker. Full gate passed.

🤖 Generated with Claude Code

shiny-code-bot and others added 2 commits September 20, 2026 21:02
Catalog refresh became operator-only on 2026-07-19 when page loads stopped
triggering it, and nothing replaced the trigger. The production catalog then
went two months without a refresh: new seasons were unknown and the wrong
season was held as current.

- A leader-owned worker starts an inventory-only refresh when the last
  finished one is older than media.catalog_refresh_hours (default 6, 0 off).
  It re-runs a refresh interrupted by a restart, waits 30 minutes after a
  failed one, and honours the background-work pause.
- The catalog reads as stale after two missed intervals instead of 15 minutes.

Refs #638

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The smoke fixtures have no media files behind them. In CI the fixture server
ran past the worker's first check, a refresh marked every fixture missing,
and the route smoke lost its seeded review links.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@shiny-code-bot
shiny-code-bot merged commit e6e0e9e into main Sep 21, 2026
7 of 8 checks passed
@shiny-code-bot
shiny-code-bot deleted the work/638-automatic-catalog-refresh branch September 21, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant