a2bfa8ea71
Add srrdb_log table with composite primary key (day, category) and counters found, stored, ignored plus run_at. Replace the release-only persistence path with UpsertAllSrrdbWithDay so releases and their corresponding srrdb_log row are written in one SQLite transaction. Preserve existing error handling: rollback reports the release/day that failed, and commit errors return without writing a dump. Handle fully ignored days as closed. When every fetched release is skipped by ignore rules, still write the ledger row with zero stored releases. This prevents the automatic day walk from endlessly retrying a day whose releases are filtered out. Derive and validate the ledger day from the resolved request URI. Missing or invalid date: segments now fail before database writes. Keep run_at independent from created_at semantics and continue populating created_at from the run time. Preserve column and upsert semantics. category continues to use NOT NULL DEFAULT empty string; status keeps COALESCE behavior on conflict; nfo, content, and synced_at remain unchanged.
50 lines
1.4 KiB
SQL
50 lines
1.4 KiB
SQL
CREATE TABLE IF NOT EXISTS srrdb_releases
|
|
(
|
|
"release" TEXT PRIMARY KEY NOT NULL,
|
|
date TEXT,
|
|
created_at TEXT NOT NULL,
|
|
synced_at TEXT,
|
|
category TEXT NOT NULL DEFAULT '',
|
|
status TEXT,
|
|
group_name TEXT,
|
|
has_nfo TEXT,
|
|
has_srs TEXT,
|
|
is_foreign TEXT,
|
|
imdb_id TEXT,
|
|
size INTEGER,
|
|
comment TEXT,
|
|
nfo BLOB,
|
|
content TEXT,
|
|
source TEXT,
|
|
CHECK (
|
|
status IN (
|
|
'on', 'hdd', 'hdd_e', 'catalogued',
|
|
'deferred', 'ext', 'cloud', 'burnt', 'updated',
|
|
'onhold', 'watch', 'hidden', 'duplicate', 'trash',
|
|
'closed', 'request', '2cat', '2compare', 'neformat',
|
|
'sf88', 'BATA', 'away', 'ready2burn', 'accurip',
|
|
'replace', '2burn', 'remove', 'paid', 'free', 'ftp',
|
|
'stream', 'ai'
|
|
)
|
|
)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_srrdb_date
|
|
ON srrdb_releases (date);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_srrdb_group
|
|
ON srrdb_releases (group_name);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_srrdb_status
|
|
ON srrdb_releases (status);
|
|
|
|
CREATE TABLE IF NOT EXISTS srrdb_log
|
|
(
|
|
day TEXT NOT NULL,
|
|
category TEXT NOT NULL,
|
|
found INTEGER NOT NULL,
|
|
stored INTEGER NOT NULL,
|
|
ignored INTEGER NOT NULL,
|
|
run_at TEXT NOT NULL,
|
|
PRIMARY KEY (day, category)
|
|
); |