diff options
| author | Sam Scholten | 2026-08-30 20:34:38 +1000 |
|---|---|---|
| committer | Sam Scholten | 2026-08-30 20:34:38 +1000 |
| commit | eff960c54620bfba47d40bc3792ba805dea3dab3 (patch) | |
| tree | a04fd365bb08a5a043b99665f8d7435ba1e989e0 /cmds/serve_test.go | |
| parent | 25f47ca899527ed2b16d19209c0546413e057126 (diff) | |
| download | fluxrec-eff960c54620bfba47d40bc3792ba805dea3dab3.tar.gz fluxrec-eff960c54620bfba47d40bc3792ba805dea3dab3.zip | |
rss: provenance + score calibration in items
Item titles gain a rune-capped source-feed suffix so list views (which
only ever show the channel title) display provenance inline. Item bodies
open with feed, model score, and the batch-wide score median; the median
is computed over every scored entry at poll time and stored on the run
row as a nil-safe pointer, so old rows render without it. /api/status
exposes the median too.
Diffstat (limited to 'cmds/serve_test.go')
| -rw-r--r-- | cmds/serve_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cmds/serve_test.go b/cmds/serve_test.go index d7df2dd..e8aec19 100644 --- a/cmds/serve_test.go +++ b/cmds/serve_test.go @@ -133,6 +133,9 @@ func TestPollMultiPage(t *testing.T) { if !row.ModelCreatedAt.Equal(model.CreatedAt) { t.Errorf("model_created_at = %v, want %v", row.ModelCreatedAt, model.CreatedAt) } + if row.ScoreMedian == nil { + t.Error("score_median missing on run row (median over all scored entries)") + } } func TestPollCrashLeavesNoState(t *testing.T) { @@ -274,6 +277,20 @@ func TestAssembleBatchFewCandidates(t *testing.T) { } } +func TestMedianScore(t *testing.T) { + if m := medianScore(nil); m != nil { + t.Errorf("empty poll: median = %v, want nil (field omitted)", *m) + } + odd := []scoredEntry{{score: 0.1}, {score: 0.9}, {score: 0.5}} + if m := medianScore(odd); m == nil || *m != 0.5 { + t.Errorf("odd median = %v, want 0.5", m) + } + even := []scoredEntry{{score: 0.1}, {score: 0.5}, {score: 0.9}, {score: 0.2}} + if m := medianScore(even); m == nil || *m != 0.35 { + t.Errorf("even median = %v, want 0.35", m) + } +} + func TestParseRefreshAt(t *testing.T) { mins, err := parseRefreshAt("18:00,06:00, 12:30") if err != nil { |
