| 1 | -- Every check, kept for 7 days, and detection by N of M. |
| 2 | -- |
| 3 | -- check_history: one row per part per round of checks: how long it took, |
| 4 | -- what it meant, and the Cloudflare data centre it ran from (the answer's |
| 5 | -- cf-ray). sudo's incident page draws an incident's parts from it. Rows |
| 6 | -- older than 7 days are deleted as checks run (store.ts `record`). |
| 7 | -- |
| 8 | -- streak gains `checks` (every check in the run, good ones between |
| 9 | -- included) and `recent` (its last five, "." good, "s" slow, "x" not |
| 10 | -- answering): a draft is made at four bad of the last five, and a run ends |
| 11 | -- after three good checks in a row. Runs kept before this have neither; |
| 12 | -- the worker fills them in as all bad, in a row (detect.ts `upgradeStreak`). |
| 13 | |
| 14 | CREATE TABLE IF NOT EXISTS check_history ( |
| 15 | component TEXT NOT NULL, |
| 16 | at TEXT NOT NULL, |
| 17 | ms INTEGER, |
| 18 | outcome TEXT NOT NULL CHECK (outcome IN ('up', 'degraded', 'down')), |
| 19 | colo TEXT, |
| 20 | -- A slow answer asked again at once: the first try's time. |
| 21 | first_ms INTEGER, |
| 22 | PRIMARY KEY (component, at) |
| 23 | ); |
| 24 | CREATE INDEX IF NOT EXISTS check_history_at ON check_history (at); |
| 25 | |
| 26 | ALTER TABLE streak ADD COLUMN checks INTEGER NOT NULL DEFAULT 0; |
| 27 | ALTER TABLE streak ADD COLUMN recent TEXT NOT NULL DEFAULT ''; |