Roadmap: After Dark editorial events (Hammer Horror Double Bill, Universal Monsters Takeover, J-Horror After Midnight), proposals only
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m53s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m37s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-04 09:09:33 +00:00
co-authored by Claude Opus 5.5
parent e0d1450011
commit 0f7ce59166
4 changed files with 75 additions and 11 deletions
@@ -190,12 +190,14 @@ class WeightedRotationTest {
}
@Test fun theApprovedChannelsAreWeightedAndTotsBedtimeIsNot() {
assertEquals(listOf(101, 102, 103, 104, 106, 107, 202, 203, 601, 602, 603, 605, 614), SmartChannels.filter { it.tierWeights != null }.map { it.number }.sorted())
// Riot, Terra, Ring X and Junior keep equal turns; Rewind and Dark Files wait on their repeat investigation.
assertTrue(SmartChannels.filter { it.number in setOf(105, 201, 401, 611, 604, 204) }.all { it.tierWeights == null })
assertEquals(listOf(101, 102, 103, 104, 106, 107, 202, 203, 204, 601, 602, 603, 604, 605, 614), SmartChannels.filter { it.tierWeights != null }.map { it.number }.sorted())
// Riot, Terra, Ring X and Junior keep equal turns.
assertTrue(SmartChannels.filter { it.number in setOf(105, 201, 401, 611) }.all { it.tierWeights == null })
assertEquals(setOf(204, 601, 604), SmartChannels.filter { it.catalogueScaleHours != null }.map { it.number }.toSet())
assertEquals(TIER_SUPPORTING, SmartChannels.first { it.number == 204 }.weightOf(show("Haunted", 100, 60)), 0.0)
assertEquals(TIER_CORE, SmartChannels.first { it.number == 101 }.weightOf(show("The Wonder Years", 1)), 0.0)
assertEquals(TIER_SURPRISE, SmartChannels.first { it.number == 101 }.weightOf(show("Heartbeat", 1)), 0.0)
assertEquals(TIER_CORE, SmartChannels.first { it.number == 601 }.weightOf(show("Tenchi Muyo! Ryo-Ohki", 1)), 0.0)
assertEquals(TIER_CORE, SmartChannels.first { it.number == 601 }.weightOf(show("Tenchi Muyo! Ryo-Ohki", 100, 60)), 0.0)
assertEquals(TIER_CORE, SmartChannels.first { it.number == 106 }.weightOf(show("Doctor Who (2023)", 1)), 0.0)
val tots = SmartChannels.first { it.number == TOTS_NUMBER }
assertEquals(listOf(true, true, false, false), tots.dayParts.map { it.weighted })
@@ -211,6 +213,20 @@ class WeightedRotationTest {
assertTrue(SmartChannels.filter { it.number != 614 && it.number != 605 }.all { p -> p.dayParts.all { it.weighted && it.weights.isEmpty() } })
}
@Test fun aShortCatalogueHasItsWeightScaledDownAndSoRepeatsLessOften() {
val p = ChannelProgramming(1, "Hybrid", emptyList(), tierWeights = mapOf(seriesKey("Tiny core") to TIER_CORE), catalogueScaleHours = 24.0)
assertEquals(TIER_CORE, p.weightOf(show("Big core", 0).copy(title = "Tiny core", episodes = show("x", 60, 30).episodes)), 0.0)
assertEquals(TIER_CORE * 0.5, p.weightOf(show("Tiny core", 24, 30)), 1e-9)
assertEquals(TIER_SUPPORTING * MIN_CATALOGUE_SCALE, p.weightOf(show("Other", 1, 1)), 1e-9)
// Four weeks of a twelve-episode core show among ten big ones: scaled, it repeats far less often and still airs.
val pool = listOf(show("Tiny core", 12, 25)) + (1..10).map { show("Big $it", 300) }
fun weekly(weightOf: (PoolSeries) -> Double) = run(pool, weightOf).entries.groupBy { it.media.item.id }.values.sumOf { es -> es.zipWithNext().count { (a, b) -> b.startMs - a.startMs < 7 * day } }
val plain = ChannelProgramming(1, "Plain", emptyList(), tierWeights = p.tierWeights)
val before = weekly(plain::weightOf); val after = weekly(p::weightOf)
assertTrue("$before -> $after", after * 2 < before)
assertTrue(run(pool, p::weightOf).entries.any { it.seriesId == "Tiny core" })
}
@Test fun orbitThreesTiers() {
val three = SmartChannels.first { it.number == 103 }
assertTrue(three.searches.none { seriesKey(it) == seriesKey("Family Guy") })