diff options
Diffstat (limited to 'server/cmd')
| -rw-r--r-- | server/cmd/listend/main.go | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/server/cmd/listend/main.go b/server/cmd/listend/main.go index 377fedc..43921bd 100644 --- a/server/cmd/listend/main.go +++ b/server/cmd/listend/main.go @@ -40,6 +40,18 @@ import ( "github.com/terst/listen/server/internal/transcript" ) +// tierRankOf orders the tiers for work: topical first, archive last. +func tierRankOf(tier string) int { + switch tier { + case store.TierTopical: + return 0 + case store.TierArchive: + return 2 + default: + return 1 + } +} + // minRecurringCorpus is how many of a show's episodes must have words before what they share // means anything. Three: the target and the two others a stretch has to turn up in. const minRecurringCorpus = 3 @@ -291,7 +303,9 @@ func (w *worker) save() { // pollAll refreshes every subscribed feed, then mirrors and detects what changed. func (w *worker) pollAll(ctx context.Context) { - feeds := w.state.Feeds() + // Topical shows first and archive last, so a five-hour back-catalogue episode cannot take + // a cycle's recognition budget before the morning news has been looked at. + feeds := w.state.ByTier(w.state.Feeds()) if len(feeds) == 0 { log.Printf("no subscriptions yet; waiting for the phone to send its list") return @@ -960,8 +974,20 @@ func (w *worker) pendingRecognition() []*store.Episode { } } } + // Three things decide the order, and they are in the order they matter. A topical show is + // worthless by Thursday. An episode whose answer checks itself against the length gap is + // worth more than one that cannot. And within that, newest first. + rank := map[string]int{} + for _, show := range w.state.Shows() { + for _, e := range show.Episodes { + rank[e.ID] = tierRankOf(w.state.Tier(show.FeedURL)) + } + } sort.SliceStable(pending, func(i, j int) bool { left, right := pending[i], pending[j] + if rank[left.ID] != rank[right.ID] { + return rank[left.ID] < rank[right.ID] + } if (left.MasterCues > 0) != (right.MasterCues > 0) { return left.MasterCues > 0 } |
