A read only for waiting approvals looks up just those, not the whole list (build 69)

22 November 2026: After Dark's re-reads for its 95 waiting approvals searched its whole film list first, about 180
requests of the hour's 200, and found 4 a time. When the only reason a pool is due is approvals still waiting, the pool
is kept as it is and only those are looked up (about one request each); the list's own weekly refresh keeps its date.
Also in this build: the Orbit X ident with just the planet and a green X.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 23:17:04 +00:00
co-authored by Claude Opus 5.5
parent 26c1405f33
commit bdc4fbab94
4 changed files with 27 additions and 4 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ plugins {
id("org.jetbrains.kotlin.plugin.compose")
}
/** The release's build number: versionCode is this x 10 plus the edition's channel. */
val ORBIT_BUILD = 68
val ORBIT_BUILD = 69
android {
namespace = "tv.orbit.classic"
compileSdk = 36
@@ -379,12 +379,15 @@ internal class ChannelScheduler(private val store: ScheduleStore,
if (routine) lastRoutineRefreshMs = now
val started = android.os.SystemClock.elapsedRealtime()
try {
val read = session.readChannelPool(programming, loop, choices, checkActive, previous = cached?.series)
// Due only for approvals still waiting: those alone are read, and the rest of the pool stays as it is.
val onlyWaiting = waiting && cached != null && cached.signature == signature && !poolRefreshDue(cached.fetchedAtMs, number, now)
val read = session.readChannelPool(programming, loop, choices, checkActive, previous = cached?.series, waitingOnly = onlyWaiting)
requests = read.requests
fetchMs = android.os.SystemClock.elapsedRealtime() - started
if (read.series.isNotEmpty()) {
// A refresh that had to keep a few previous copies is tried again in a few hours rather than a week.
val fetched = if (read.carried > 0) now - POOL_REFRESH_MS + PARTIAL_POOL_RETRY_MS else now
// A read only for waiting approvals leaves the list's own refresh where it was.
val fetched = if (onlyWaiting) cached!!.fetchedAtMs else if (read.carried > 0) now - POOL_REFRESH_MS + PARTIAL_POOL_RETRY_MS else now
if (read.carried > 0) Log.w("OrbitSchedule", "channel=$number poolRefreshPartial carried=${read.carried}")
val signed = keepRefound(userId, programming, read)
pool = ScheduleStore.SavedPool(read.series, fetched, signed)
@@ -378,10 +378,17 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v
/** The first shows in the channel's list that have episodes to schedule. */
fun readChannelPool(programming: ChannelProgramming, loop: SampleChannel?, choices: ChannelChoices = ChannelChoices(), checkActive: () -> Unit = {},
/** The pool being refreshed, so one show whose read fails can keep its copy rather than losing the whole refresh. */
previous: List<PoolSeries>? = null): PoolRead {
previous: List<PoolSeries>? = null,
/**
* Only the approvals still waiting to be found (22 November 2026): the rest of the pool is kept as it is, so a read
* that's only for them costs about a request each, not a whole list's search (After Dark's 180) every time.
*/
waitingOnly: Boolean = false): PoolRead {
var requests = 0
val pool = mutableListOf<PoolSeries>()
val partial = PartialRead(previous)
if (waitingOnly && previous != null) pool += previous
if (!(waitingOnly && previous != null)) {
if (programming.filmRestMs != null) {
// Films already in this channel's old line-up stay in it, unless the list now names another film of that title.
val listed = programming.searches.map { seriesKey(FilmIdentity.of(it).title) }.toSet()
@@ -461,6 +468,7 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v
val film = lookup.film ?: continue
if (pool.none { it.id == film.id }) pool += film
}
}
// One slow or failing series among many chosen (Sakura's 200, 7 November 2026) is skipped this time rather than failing
// the whole read; it's tried again at the next refresh. A provider that keeps failing still stops the read.
var skipped = 0
@@ -365,4 +365,16 @@ class WaitingApprovalsTest {
assertEquals(setOf("new1", "new2", "new3"), store.loadPool(user, 701)!!.series.map { it.id }.toSet())
dir.deleteRecursively()
}
@Test fun aReadOnlyForWaitingApprovalsSearchesNothingElse() {
val asked = mutableListOf<String>()
val inner = transport { true }
val session = EmbySampleSession(EmbyTransport { r -> asked += r.path; inner.execute(r) }, "fixture-token-private", user, EmbySample(emptyList(), 0))
val listed = ChannelProgramming(305, "After Dark", listOf("Some Film (1980)", "Another Film (1981)"), filmRestMs = 1L)
val kept = listOf(PoolSeries("k1", "Some Film", listOf(PoolEpisode("k1", "s1", EpisodeMark(1, 1), "Some Film", 5_400_000L))))
val read = session.readChannelPool(listed, null, approvals, previous = kept, waitingOnly = true)
assertTrue(asked.none { "SearchTerm" in it }) // the list isn't searched again
assertEquals(setOf("k1", "new1", "new2", "new3"), read.series.map { it.id }.toSet())
assertEquals(3, asked.count { "AnyProviderIdEquals" in it })
}
}