Drive-In event ideas, phase 2: Approve, Defer and Dismiss
Approved by Paul on 5 November 2026. The idea pop-up in the Director's Chair now offers Approve, Defer and Dismiss. Approve keeps each film's identity (title, year, IMDb ID, library item) in the history and turns the idea into a Drive-In event booked exactly like the ten curated ones: only once the Drive-In's plan reaches its evening, only appending, and only if every film passes the box's checks again then. Defer brings an idea back after four weeks; Dismiss drops it unless its films change. Approved events count for editorial competition and evenings like the curated ones. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -95,4 +95,33 @@ class EventIdeasTest {
|
||||
assertEquals("proposed", EventIdeaHistory.load(file).single().optString("decision"))
|
||||
assertEquals(2L, EventIdeaHistory.load(file).single().optLong("shownMs"))
|
||||
}
|
||||
|
||||
@Test fun anApprovedIdeaBecomesADriveInEventAndBooksLikeOne() {
|
||||
val history = java.io.File.createTempFile("history", ".json").apply { deleteOnExit(); writeText("[]") }
|
||||
val ideasFile = java.io.File.createTempFile("ideas", ".json").apply { deleteOnExit() }
|
||||
val a = film("5000001", "Comedy One", setOf("Comedy"), "U", 8.0, 1949, 81, "tt0041546"); val b = film("5000002", "Comedy Two", setOf("Comedy"), "U", 7.5, 1951, 78, "tt0044829")
|
||||
val idea = EventIdea("studio:Ealing Studios|FridayDouble", "Ealing Comedy Night", "studio", IdeaFormat.FridayDouble, java.time.LocalDateTime.of(2026, 11, 20, 20, 0), listOf(a, b), listOf("why"), 8.0)
|
||||
EventIdeaHistory.record(history, listOf(idea), 1)
|
||||
ideasFile.writeText(org.json.JSONObject().put("ideas", org.json.JSONArray(EventIdeaHistory.load(history))).toString())
|
||||
assertTrue(EventIdeaHistory.decide(history, ideasFile, idea.signature, "approved", listOf(a, b), 2))
|
||||
val event = EventIdeaHistory.approvedEvents(history).single()
|
||||
assertEquals(LocalDate.of(2026, 11, 20), event.evening); assertEquals(20, event.hour); assertEquals(listOf("5000001", "5000002"), event.films.map { it.itemId })
|
||||
assertEquals("tt0041546", event.films.first().imdb)
|
||||
assertTrue(allDriveInEvents().any { it.name == "Ealing Comedy Night" }) // the Drive-In books it like its own
|
||||
assertEquals("approved", org.json.JSONObject(ideasFile.readText()).getJSONArray("ideas").getJSONObject(0).optString("decision"))
|
||||
assertTrue(idea.signature in EventIdeaHistory.dismissed(history, 3)) // never proposed again
|
||||
// It books on its evening, from the verified films, as the curated events do.
|
||||
val pool = (1..40).map { n -> PoolSeries("p$n", "Film $n", listOf(PoolEpisode("p$n", "s$n", EpisodeMark(1, 1), "Film $n", 100 * 60_000L))) }
|
||||
val verified = listOf(a, b).associate { f -> f.id to PoolSeries(f.id, f.title, listOf(PoolEpisode(f.id, "src", EpisodeMark(1, 1), f.title, f.runtimeMs!!))) }
|
||||
var plan: ChannelPlan? = null; var now = java.time.ZonedDateTime.of(2026, 11, 12, 12, 0, 0, 0, london).toInstant().toEpochMilli()
|
||||
repeat(9) { plan = planDriveIn(plan, pool, pool, pool, now, london, events = listOf(event), eventFilms = verified); now += 24 * 60 * 60_000L }
|
||||
val booked = plan!!.entries.filter { it.seriesId in verified.keys }
|
||||
assertEquals(listOf("5000001", "5000002"), booked.map { it.seriesId })
|
||||
assertTrue(booked.first().why.startsWith(DRIVE_IN_EVENT_WHY))
|
||||
// Deferred: back after four weeks; dismissed: not again.
|
||||
val h2 = java.io.File.createTempFile("history", ".json").apply { deleteOnExit(); writeText("[]") }
|
||||
EventIdeaHistory.record(h2, listOf(idea), 1); EventIdeaHistory.decide(h2, ideasFile, idea.signature, "deferred", emptyList(), 10)
|
||||
assertTrue(idea.signature in EventIdeaHistory.dismissed(h2, 10 + EVENT_IDEA_DEFER_MS - 1)); assertFalse(idea.signature in EventIdeaHistory.dismissed(h2, 10 + EVENT_IDEA_DEFER_MS))
|
||||
ApprovedDriveInEvents.list = emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user