From ca4cd230a47501f4d8aaaa4568a3fa59a43a9706 Mon Sep 17 00:00:00 2001 From: Quick <31828688+Quick104@users.noreply.github.com> Date: Fri, 29 May 2026 10:40:58 -0400 Subject: [PATCH] feat(sections): add trending_discover_snapshots table --- .../166_trending_discover_snapshots.down.sql | 1 + .../166_trending_discover_snapshots.up.sql | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 migrations/166_trending_discover_snapshots.down.sql create mode 100644 migrations/166_trending_discover_snapshots.up.sql diff --git a/migrations/166_trending_discover_snapshots.down.sql b/migrations/166_trending_discover_snapshots.down.sql new file mode 100644 index 00000000..72a6d6d4 --- /dev/null +++ b/migrations/166_trending_discover_snapshots.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS public.trending_discover_snapshots; diff --git a/migrations/166_trending_discover_snapshots.up.sql b/migrations/166_trending_discover_snapshots.up.sql new file mode 100644 index 00000000..706d5c83 --- /dev/null +++ b/migrations/166_trending_discover_snapshots.up.sql @@ -0,0 +1,16 @@ +-- Persisted snapshot of external global trending (TMDB / Trakt) for the +-- trending_discover home section. One row per canonical (source, time_window): +-- content_ids are already resolved to library catalog content IDs and ordered +-- by trending rank. A background task refreshes these rows; the section read +-- path only reads them, so a slow or down provider never blocks the home page. +CREATE TABLE public.trending_discover_snapshots ( + source text NOT NULL, -- 'tmdb' | 'trakt' + time_window text NOT NULL, -- 'day' | 'week' (trakt pinned to 'week') + content_ids text[] NOT NULL DEFAULT '{}'::text[], + entry_count integer NOT NULL DEFAULT 0, -- raw provider entries fetched + refreshed_at timestamptz, -- last successful refresh + last_attempt_at timestamptz, -- last attempt (success or failure) + last_status text NOT NULL DEFAULT '', -- 'ok' | 'empty' | 'error' + last_error text NOT NULL DEFAULT '', + PRIMARY KEY (source, time_window) +);