Rewrites the internal/db/queries comments to rule 32 and regenerates dbq, whose doc comments and embedded SQL carry them. The bugs behind the tiered mixes, the md5 order seed, the score bands and the round-robin arms are restated as the constraint each one enforces; counts from one library and stale cross-references are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
3.0 KiB
Go
78 lines
3.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: admin_summary.sql
|
|
|
|
package dbq
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const adminSummary = `-- name: AdminSummary :one
|
|
SELECT
|
|
(SELECT count(*) FROM requests WHERE status = 'pending')::bigint AS requests,
|
|
(SELECT min(requested_at) FROM requests WHERE status = 'pending')::timestamptz AS requests_since,
|
|
-- A broken track is one report however it was found: a listener flagged
|
|
-- it, or it failed to play. Counted by track, as the Reports
|
|
-- page lists them.
|
|
(SELECT count(*) FROM (
|
|
SELECT track_id FROM quarantine
|
|
UNION
|
|
SELECT track_id FROM playback_errors WHERE resolved_at IS NULL) r)::bigint AS reports,
|
|
(SELECT min(at) FROM (
|
|
SELECT created_at AS at FROM quarantine
|
|
UNION ALL
|
|
SELECT occurred_at FROM playback_errors WHERE resolved_at IS NULL) r)::timestamptz AS reports_since,
|
|
-- Duplicates needing review: a cross-release group is kept and linked by
|
|
-- the resolver and waits on nobody (the report's review view).
|
|
(SELECT count(*) FROM duplicate_groups g
|
|
WHERE g.status = 'pending' AND g.class IS DISTINCT FROM 'cross_release'
|
|
AND (SELECT count(*) FROM duplicate_group_members m WHERE m.group_id = g.id) >= 2)::bigint AS duplicates,
|
|
(SELECT min(g.detected_at) FROM duplicate_groups g
|
|
WHERE g.status = 'pending' AND g.class IS DISTINCT FROM 'cross_release'
|
|
AND (SELECT count(*) FROM duplicate_group_members m WHERE m.group_id = g.id) >= 2)::timestamptz AS duplicates_since,
|
|
(SELECT count(*) FROM tracks WHERE source_verdict = 'suspect' AND missing_since IS NULL)::bigint AS suspect,
|
|
(SELECT min(source_verdict_at) FROM tracks WHERE source_verdict = 'suspect' AND missing_since IS NULL)::timestamptz AS suspect_since,
|
|
(SELECT count(*) FROM tracks WHERE missing_since IS NOT NULL)::bigint AS missing,
|
|
(SELECT min(missing_since) FROM tracks WHERE missing_since IS NOT NULL)::timestamptz AS missing_since
|
|
`
|
|
|
|
type AdminSummaryRow struct {
|
|
Requests int64
|
|
RequestsSince pgtype.Timestamptz
|
|
Reports int64
|
|
ReportsSince pgtype.Timestamptz
|
|
Duplicates int64
|
|
DuplicatesSince pgtype.Timestamptz
|
|
Suspect int64
|
|
SuspectSince pgtype.Timestamptz
|
|
Missing int64
|
|
MissingSince pgtype.Timestamptz
|
|
}
|
|
|
|
// What the admin rail and the Overview's verdict read: each queue
|
|
// that waits on a person, with how many and since when. One round trip, so
|
|
// the rail costs one cheap read on every admin page. The "since" is the
|
|
// oldest item still waiting: how long the queue has been left, which is what
|
|
// tells an admin a count of 2 is fine today and wrong after a month.
|
|
func (q *Queries) AdminSummary(ctx context.Context) (AdminSummaryRow, error) {
|
|
row := q.db.QueryRow(ctx, adminSummary)
|
|
var i AdminSummaryRow
|
|
err := row.Scan(
|
|
&i.Requests,
|
|
&i.RequestsSince,
|
|
&i.Reports,
|
|
&i.ReportsSince,
|
|
&i.Duplicates,
|
|
&i.DuplicatesSince,
|
|
&i.Suspect,
|
|
&i.SuspectSince,
|
|
&i.Missing,
|
|
&i.MissingSince,
|
|
)
|
|
return i, err
|
|
}
|