Runs (migration 0011): a run groups the cycles of one launch. It opens when an address enters an idle queue, takes everything submitted or re-checked while it is open and is finalized when all its addresses are done; a re-check after that opens a new run, so results of different runs never mix. check_runs, run_results (one result per address and run, with the verdict and the expected and stored check counts), subnets, run_id on ip_queue and checks. Existing data is split into runs at pauses of more than an hour; ingress checks get the validator that held the address (also at write time from now on). Analytics (internal/analytics): figures computed from the stored checks of the latest cycle of each address in the run, as facts next to the verdict: summary, reasons of partial, data quality, subnets, targets and the subnet x target matrix by check type, ingress by site, error classes, validators, and the address lists behind the indicators and error classes. API: analytics runs, report, lists (JSON or CSV), subnet list; run and subnet filters for the registry. Dashboard: /analytics matching the approved mockup (run selector, indicators with address lists and CSV, error-class dialogs, drill-down to the registry), subnet list on /settings. Sidebar: the control-api link state, theme toggle and logout moved to the top, the three dots next to the logo removed, sections grouped. Rebuilt bin/control-api and bin/admin-dashboard to match. Plan, summary and the updated README, API, USAGE, DASHBOARD and ADMIN_CLEANUP docs are in docs/. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
40 lines
902 B
Go
40 lines
902 B
Go
package analytics
|
|
|
|
import (
|
|
"context"
|
|
|
|
"cloudipvalidator/internal/db"
|
|
)
|
|
|
|
// Load reads a finished run from the database and computes its analysis.
|
|
func Load(ctx context.Context, d *db.DB, runID int64) (*Analysis, error) {
|
|
run, err := d.GetRun(ctx, runID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
results, err := d.ListRunResults(ctx, runID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
subnets, err := d.ListSubnets(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
sites, err := d.ListSites(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
names := map[int]string{}
|
|
for _, s := range sites {
|
|
names[s.Index] = s.SiteID
|
|
}
|
|
rechecked, err := d.CountRecheckedInRun(ctx, runID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return Compute(Input{
|
|
Run: *run, Results: results, Subnets: subnets, SiteNames: names, Rechecked: rechecked,
|
|
Each: func(fn func(db.RunCheck)) error { return d.EachRunCheck(ctx, runID, fn) },
|
|
})
|
|
}
|