0.1.52 Gateway

This commit is contained in:
ponzischeme89
2026-08-17 19:09:17 +12:00
parent d5a8d3ad88
commit 1da91e40a1
46 changed files with 1626 additions and 106 deletions
+21
View File
@@ -57,6 +57,27 @@ CREATE TABLE IF NOT EXISTS device_versions (
CREATE INDEX IF NOT EXISTS device_versions_recent_idx
ON device_versions (device_id, last_seen_at DESC);
-- One row per television per day it was used.
--
-- It exists to answer "is this the first time this set has opened Memby today", which is
-- a question a counter or a timestamp cannot answer safely: every television in the house
-- asks at once, so the answer has to come from the insert itself. The primary key is what
-- makes it atomic — the row either went in, which means first, or it did not.
--
-- The day is the *household's* local day, computed against MEMBY_TIMEZONE and stored as a
-- plain date, because "today" is a thing the people watching have an opinion about and
-- UTC does not agree with it for most of a New Zealand evening.
CREATE TABLE IF NOT EXISTS device_activity_days (
device_id TEXT NOT NULL,
emby_user_id TEXT NOT NULL,
day DATE NOT NULL,
first_seen_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (device_id, emby_user_id, day)
);
CREATE INDEX IF NOT EXISTS device_activity_days_day_idx
ON device_activity_days (day);
-- The imported library.
--
-- payload is Emby's item JSON verbatim, so rows served from here are byte-identical to