Add activity tracker server, Hyprland agent and Gitea image publishing
Test and publish / test (push) Successful in 2m38s
Test and publish / publish (push) Failing after 2m30s

The Go API on PostgreSQL ingests desktop, browser, presence, manual and
Health Auto Export events and serves activities and daily goal summaries.
The Hyprland agent records window focus, idle and lock intervals.

The CI workflow publishes adam-french.co.uk/adamf/activity-tracker to the
Gitea registry and rolls the web_server stack onto it. The image probes
itself through a new `tracker healthcheck` command, because distroless
has no wget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-14 20:38:12 +01:00
co-authored by Claude Opus 5.5
parent 0cbbb76dee
commit f4ce04875c
29 changed files with 2810 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
-- +goose Up
CREATE TABLE devices (
id bigserial PRIMARY KEY,
name text NOT NULL UNIQUE,
kind text NOT NULL,
api_key_hash text NOT NULL UNIQUE,
created_at timestamptz NOT NULL DEFAULT now(),
last_seen_at timestamptz,
revoked_at timestamptz
);
CREATE TABLE activities (
id bigserial PRIMARY KEY,
device_id bigint NOT NULL REFERENCES devices (id),
source text NOT NULL,
kind text NOT NULL,
label text NOT NULL DEFAULT '',
started_at timestamptz NOT NULL,
ended_at timestamptz NOT NULL,
duration_s integer GENERATED ALWAYS AS (extract(epoch FROM ended_at - started_at)::integer) STORED,
attrs jsonb NOT NULL DEFAULT '{}',
external_id text NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
CHECK (ended_at >= started_at),
UNIQUE (source, external_id)
);
CREATE INDEX activities_started_at_idx ON activities (started_at);
CREATE INDEX activities_kind_started_at_idx ON activities (kind, started_at);
CREATE INDEX activities_label_idx ON activities (label);
-- Point-in-time metrics such as step counts or heart rate.
CREATE TABLE samples (
id bigserial PRIMARY KEY,
device_id bigint NOT NULL REFERENCES devices (id),
source text NOT NULL,
metric text NOT NULL,
ts timestamptz NOT NULL,
value double precision NOT NULL,
unit text NOT NULL DEFAULT '',
external_id text NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (source, external_id)
);
CREATE INDEX samples_metric_ts_idx ON samples (metric, ts);
-- Daily targets, e.g. kind=tab_focus label=youtube.com op=<= target_s=3600.
-- An empty label matches every label of that kind.
CREATE TABLE goals (
id bigserial PRIMARY KEY,
kind text NOT NULL,
label text NOT NULL DEFAULT '',
op text NOT NULL CHECK (op IN ('>=', '<=')),
target_s integer NOT NULL CHECK (target_s >= 0),
period text NOT NULL DEFAULT 'day' CHECK (period IN ('day')),
created_at timestamptz NOT NULL DEFAULT now()
);
-- Output of future AI analysis jobs.
CREATE TABLE reports (
id bigserial PRIMARY KEY,
period_start timestamptz NOT NULL,
period_end timestamptz NOT NULL,
model text NOT NULL,
prompt_hash text NOT NULL,
body text NOT NULL,
created_at timestamptz NOT NULL DEFAULT now()
);
-- +goose Down
DROP TABLE reports;
DROP TABLE goals;
DROP TABLE samples;
DROP TABLE activities;
DROP TABLE devices;