Two new Series filters: failing, and the unverified Reader subset (#166)

This commit is contained in:
2026-08-22 23:43:47 +07:00
parent 5a32943528
commit 8a56907558
4 changed files with 224 additions and 14 deletions
+48 -2
View File
@@ -3065,8 +3065,8 @@ func TestOverviewFinishedFigureRidesLast(t *testing.T) {
}
labels = append(labels, m[1])
}
if len(labels) != 8 {
t.Fatalf("hygiene block renders %d figures, want 8 (seven problems + finished):\n%s", len(labels), body)
if len(labels) != 10 {
t.Fatalf("hygiene block renders %d figures, want 10 (nine problems + finished):\n%s", len(labels), body)
}
if labels[len(labels)-1] != "Finished" {
t.Errorf("finished figure does not ride last; hygiene order = %v:\n%s", labels, body)
@@ -4045,3 +4045,49 @@ func TestRemoveRejectsBadKeysAndCapsBody(t *testing.T) {
t.Errorf("an oversized body still removed the row:\n%s", list)
}
}
// The failing pair render in the stats block from the same aggregate the
// select is numbered from: failing over 12h counts every Series with a
// failure row older than the cutoff, unverified the Reader-attributed
// subset, and a measured zero stays a muted digit — never a door.
func TestOverviewFailingAndUnverifiedFigures(t *testing.T) {
st, dsn := newTestStoreURL(t)
db, err := sql.Open("pgx", dsn)
if err != nil {
t.Fatalf("open %s: %v", dsn, err)
}
defer db.Close()
now := time.Now().UnixMilli()
seedSeriesRow(t, st, db, seriesRowSeed{key: "asura:broken", url: "u", cover: "c", checkedAt: now, latestNum: floatPtr(1), bookmarks: 1})
seedSeriesRow(t, st, db, seriesRowSeed{key: "asura:reader", url: "u", cover: "c", checkedAt: now, latestNum: floatPtr(2), bookmarks: 1, raisedBy: true})
if err := st.RecordSeriesFailure("asura", "broken", "not_found", now-24*3600*1000); err != nil {
t.Fatalf("seed failure row on broken: %v", err)
}
if err := st.RecordSeriesFailure("asura", "reader", "not_found", now-24*3600*1000); err != nil {
t.Fatalf("seed failure row on reader: %v", err)
}
srv := newRouter(st, testConfig())
body := overviewBody(t, srv, st)
if !strings.Contains(body, `href="/admin/series?filter=failing">2</a>`) {
t.Errorf("the failing figure lacks its count and door:\n%s", body)
}
if !strings.Contains(body, `href="/admin/series?filter=unverified">1</a>`) {
t.Errorf("the unverified figure lacks its count and door:\n%s", body)
}
empty, emptySt := newWebTestServer(t, testConfig())
body = overviewBody(t, empty, emptySt)
if !strings.Contains(body, `Failing over 12h</span><span class="fig zero">0</span>`) {
t.Errorf("a zero failing figure does not render as a muted digit:\n%s", body)
}
if !strings.Contains(body, `Unverified Reader number</span><span class="fig zero">0</span>`) {
t.Errorf("a zero unverified figure does not render as a muted digit:\n%s", body)
}
if strings.Contains(body, `href="/admin/series?filter=failing"`) {
t.Errorf("a zero failing figure is still a link:\n%s", body)
}
if strings.Contains(body, `href="/admin/series?filter=unverified"`) {
t.Errorf("a zero unverified figure is still a link:\n%s", body)
}
}