diff options
Diffstat (limited to 'server/cmd')
| -rw-r--r-- | server/cmd/listend/shadow.go | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/server/cmd/listend/shadow.go b/server/cmd/listend/shadow.go index 7531115..03f4b71 100644 --- a/server/cmd/listend/shadow.go +++ b/server/cmd/listend/shadow.go @@ -56,8 +56,24 @@ func (w *worker) runShadow(ctx context.Context, show *store.Show, episodes []*st Occasion: show.FeedURL + "@" + show.DetectedBatch, AtUnix: time.Now().Unix(), } + // What the listener has said, indexed so each episode can pick up its own. Labels outlive + // the episodes they were given on, so most of these belong to batches long since rotated + // out; only the ones matching this batch's guids are of any use here. + labels := map[string][]signature.ShadowLabel{} + for _, l := range w.state.Labels() { + if l.FeedURL != show.FeedURL { + continue + } + labels[l.GUID] = append(labels[l.GUID], signature.ShadowLabel{ + StartMs: l.StartMs, + EndMs: l.EndMs, + Advertising: l.Verdict == store.LabelAd, + EndMeasured: l.EndMeasured, + }) + } + for _, e := range episodes { - ep := signature.ShadowEpisode{ID: e.ID, FeedURL: show.FeedURL} + ep := signature.ShadowEpisode{ID: e.ID, FeedURL: show.FeedURL, Labels: labels[e.GUID]} for _, br := range e.Breaks { ep.Breaks = append(ep.Breaks, signature.ShadowBreak{ StartMs: br.StartMs, @@ -81,11 +97,12 @@ func (w *worker) runShadow(ctx context.Context, show *store.Show, episodes []*st novel++ } } - log.Printf("%s: shadow -- learned %d, reinforced %d, library %d (%d worth matching); "+ + log.Printf("%s: shadow -- learned %d, reinforced %d%s, library %d (%d worth matching); "+ "would cut %d, %d of them new%s, took %s", - show.Title, report.Harvested, report.Reinforced, w.signatures.Len(), - len(w.signatures.Trusted(shadowMinOccasions)), len(report.WouldCut), novel, - skippedNote(report.Skipped), time.Since(started).Round(time.Second)) + show.Title, report.Harvested, report.Reinforced, disownedNote(report.Disowned), + w.signatures.Len(), len(w.signatures.Trusted(shadowMinOccasions)), + len(report.WouldCut), novel, skippedNote(report.Skipped), + time.Since(started).Round(time.Second)) // The novel ones are the whole point: what the library would add to what detection already // publishes. Logged individually so they can be listened to and judged. @@ -104,6 +121,15 @@ func (w *worker) runShadow(ctx context.Context, show *store.Show, episodes []*st } } +// disownedNote reports signatures taken back because the listener said that audio is the +// programme. Always logged when it happens: it is the library being told it was wrong. +func disownedNote(n int) string { + if n == 0 { + return "" + } + return fmt.Sprintf(", disowned %d", n) +} + func skippedNote(n int) string { if n == 0 { return "" |
