gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit4ecc67b24ecc67b2tracker: STATUS/LOG for the t38 + t40 merge (gates 374/0, 32/0, 53/0, 229/0, 26/0, check-theme 0; live copy checks)mre4ecc67b2/lib/jobs.hl

39.9 KB

  1. // lib/jobs.hl — THE BACKGROUND JOBS (mission 028: out of project.hl, unchanged): the daily TMDB sync run, the adult and kind
  2. // backfills, the details repair, the credits job, the duplicate merge, the short-id backfill and the collection seed — each with
  3. // its queue, its pause, its log lines, and the clocks that drive them (which job runs when, which one waits for which) — and, last,
  4. // the curated franchise seed (tracker#40). The work of ONE step is the topic's own (sync.hl, backfill.hl, details.hl, credits.hl,
  5. // merge.hl, shortids.hl, collections.hl, franchiseseed.hl).
  6. // A CLASS, not statics: its state (queues, positions, totals) is rewritten on every step, and a static cannot be reassigned —
  7. // project.hl makes the one instance (`jobs = new Jobs()`) after the server, as these lines ran there before; constructing it
  8. // starts the clocks and logs which jobs are off.
  9. import { env } from 'hl:proc'
  10. import { readFile, exists } from 'hl:fs'
  11. import { now, timestamp, every } from 'hl:time'
  12. import { syncEnabled, pauseMsAfter, msPerRequest } from './tmdb.hl'
  13. import { persistSync } from './sync.hl'
  14. import { emptyTotals, addTotals, totalsLine } from './sync-helpers.hl'
  15. import { planStart, planStep, planIds, planLine, markSynced, syncRunStep } from './dailysync.hl'
  16. import { adultBackfillQueue, backfillTitle, kindBackfillQueue, kindTitle, tvmazeStatusQueue, tvmazeStatusTitle } from './backfill.hl'
  17. import { detailsRepairQueue, completeStep, persistDetails, applySynced } from './details.hl'
  18. import { persistCredits, creditsQueue, creditsStep } from './credits.hl'
  19. import { allFollowedShowIds } from './follows.hl'
  20. import { refreshCatalogShow } from './catalog.hl'
  21. import { searchTitleChanged, searchTitleRenamed } from './search.hl'
  22. import { mergePrepare, mergeStep, mergeStats, mergeLine, persistMerge } from './merge.hl'
  23. import { shortIdStep, shortIdStats, persistShortIds, shortIdsLeft } from './shortids.hl'
  24. import { seedPrepare, seedStep, seedLine, seedPersist } from './collections.hl'
  25. import { franchiseSeedPrepare, franchiseSeedStep, franchiseSeedLine, franchiseSeedStats } from './franchiseseed.hl'
  26. // ---- THE DAILY TMDB SYNC (tracker.worldapi.org#9, sync.hl; tracker#18, dailysync.hl) -------------------------
  27. // Once a day at TRACKER_SYNC_HOUR (UTC, default 4 — hl:time has no time zones; the container runs UTC). hl:web serves ONE
  28. // request at a time, so the run never takes the server for itself: a 1-second clock does ONE step per tick and returns — the
  29. // requests that queued meanwhile are served between two ticks, and a tick never starts inside a page render.
  30. // tracker#18: the run first asks TMDB's and TVmaze's CHANGE LISTS since the last run (dailysync.hl — one list page per step)
  31. // and then syncs only the titles of ours that changed, followed ones first — every title stays current, not only the followed
  32. // ones. FULL WALK (every followed show, as before #18) on the first run, after a gap > 14 days, or when a change list fails.
  33. // A title's step: sync.hl syncShow (1–3 TMDB requests + maybe its poster, TVmaze) + details.hl applySynced (the record's
  34. // title, overview, tagline … and cast/crew from the same details answer). After a step that made n requests the next waits
  35. // n × 260 ms (TMDB: ≤ 40 requests / 10 s) + 550 ms per TVmaze request (≤ 20 / 10 s, tracker.worldapi.org#12).
  36. // The finished run stores its day (dailysync.hl markSynced). Log: "tmdb sync: start, …", the change lists ("tmdb sync:
  37. // changes since …"), errors, slow steps, "tmdb sync done: mode=… changeRequests=… <totals>".
  38. // TRACKER_SYNC=0 switches it off; without TMDB_READ_TOKEN it is off too (logged once).
  39. syncHour = env('TRACKER_SYNC_HOUR') != null ? toNumber(env('TRACKER_SYNC_HOUR')) : 4
  40. syncOn = env('TRACKER_SYNC') != '0' && syncEnabled
  41. syncQueue = []
  42. syncPlanning = false
  43. syncMode = ''
  44. syncMark = false
  45. syncChangeRequests = 0
  46. syncAt = 0
  47. syncDay = ''
  48. syncNextAt = 0
  49. syncTotals = emptyTotals()
  50. syncFinish = () => {
  51. persistDetails()
  52. if (syncMark) { markSynced(syncDay) }
  53. console.log('tmdb sync done: mode=' + syncMode + ' changeRequests=' + syncChangeRequests + ' ' + totalsLine(syncTotals) + ' seconds=' + ((now() - syncAt) / 1000))
  54. return null
  55. }
  56. syncTick = () => {
  57. t = now()
  58. if (syncQueue.length == 0 && !syncPlanning) {
  59. stamp = timestamp(t)
  60. day = stamp.slice(0, 10)
  61. if (toNumber(stamp.slice(11, 13)) != syncHour || day == syncDay) { return null }
  62. syncDay = day
  63. syncAt = t
  64. syncNextAt = 0
  65. syncTotals = emptyTotals()
  66. syncChangeRequests = 0
  67. p = planStart(day, null)
  68. syncMode = p.mode
  69. syncMark = true
  70. if (p.mode == 'delta') {
  71. syncPlanning = true
  72. console.log('tmdb sync: start, changes ' + p.why)
  73. return null
  74. }
  75. syncQueue = allFollowedShowIds()
  76. console.log('tmdb sync: start, ' + syncQueue.length + ' followed shows, full walk (' + p.why + ')')
  77. if (syncQueue.length == 0) { syncFinish() }
  78. return null
  79. }
  80. if (t < syncNextAt) { return null }
  81. if (syncPlanning) {
  82. ps = planStep()
  83. syncChangeRequests = syncChangeRequests + ps.requests + ps.tvmazeRequests
  84. syncTotals.requests = syncTotals.requests + ps.requests
  85. syncTotals.tvmazeRequests = syncTotals.tvmazeRequests + ps.tvmazeRequests
  86. syncNextAt = now() + pauseMsAfter(ps)
  87. if (!ps.done) { return null }
  88. syncPlanning = false
  89. console.log('tmdb sync: ' + planLine())
  90. if (ps.failed != '') {
  91. // a change list could not be read: the old full walk, and the day is not advanced (the next run asks again)
  92. syncMode = 'full'
  93. syncMark = false
  94. syncQueue = allFollowedShowIds()
  95. console.log('tmdb sync: change list failed, full walk of ' + syncQueue.length + ' followed shows instead')
  96. } else {
  97. syncQueue = planIds()
  98. }
  99. if (syncQueue.length == 0) { syncFinish() }
  100. return null
  101. }
  102. id = syncQueue[0]
  103. rest = []
  104. let i = 1
  105. while (i < syncQueue.length) { rest.push(syncQueue[i]) i = i + 1 }
  106. syncQueue = rest
  107. // tracker#18: in a delta run a title nobody follows gets the light step (changed seasons, no TVmaze); tracker#35: one only on
  108. // TVmaze's change list its TVmaze status (dailysync.hl syncRunStep)
  109. r = syncRunStep(id, syncMode == 'delta')
  110. // tracker#18 + #28: the record's own fields (title, overview, tagline …) and the cast + crew from the same details answer
  111. if (r.details != null) {
  112. c = applySynced(id, r.details)
  113. if (c.error != '') { console.log('tmdb sync: ' + c.error) }
  114. if (c.renamed) { searchTitleRenamed(id) }
  115. }
  116. // the public lists (catalog.hl, tracker.worldapi.org#13): this show's place by its newest released episode; the sync
  117. // also brings TMDB's adult flag (mission 054) → the search's view of it too
  118. refreshCatalogShow(id)
  119. searchTitleChanged(id)
  120. took = now() - t
  121. syncTotals = addTotals(syncTotals, r)
  122. if (r.error != '') { console.log('tmdb sync: ' + r.error) }
  123. // a step blocks every request meanwhile (Saturday Night Live, 53 seasons, 4 requests: ~1.7 s) — say so in the log
  124. if (took > 1500) { console.log('tmdb sync: slow step, show ' + id + ', ' + r.requests + ' requests, ' + took + ' ms') }
  125. syncNextAt = now() + pauseMsAfter(r)
  126. if (syncQueue.length > 0 && syncTotals.shows % 10 == 0) { persistDetails() }
  127. if (syncQueue.length == 0) { syncFinish() }
  128. return null
  129. }
  130. // ---- THE ADULT-FLAG BACKFILL (mission 054, backfill.hl backfillTitle) -----------------------------------
  131. // The public lists and the search show only titles TMDB says are not adult (shows.hl isPublicTitle; unknown = hidden). At
  132. // start the app collects every title whose flag is still unknown and asks TMDB for ONE title per step — like the daily
  133. // sync, on the same clock, so requests queued meanwhile are served between two steps: one details request (adult,
  134. // poster_path, external ids) + the poster file when missing, then a pause of 260 ms per TMDB API request (≤ 40 / 10 s;
  135. // the poster comes from TMDB's image host, not the API, and is not counted). Each answered title goes into the lists
  136. // (catalog.hl refreshCatalogShow) and the search at once. RESUMES after a restart: the queue is built from what is
  137. // still unknown. Stops when the queue is empty; titles TMDB answers 404 for are marked (`adultCheck`) and stay hidden; a
  138. // passing failure (no answer, 429, 5xx) goes to the back of the queue, at most 2 more tries per start.
  139. // While the daily sync runs, the backfill waits. Log: start, every TRACKER_BACKFILL_LOG_EVERY (500) titles, done.
  140. // TRACKER_BACKFILL=0 switches it off; without TMDB_READ_TOKEN it is off too.
  141. backfillOn = env('TRACKER_BACKFILL') != '0' && syncEnabled
  142. backfillLogEvery = env('TRACKER_BACKFILL_LOG_EVERY') != null ? toNumber(env('TRACKER_BACKFILL_LOG_EVERY')) : 500
  143. backfillQueue = null
  144. backfillPos = 0
  145. backfillDone = false
  146. backfillAt = 0
  147. backfillNextAt = 0
  148. backfillTries = {}
  149. backfillTotals = { titles = 0 adult = 0 notAdult = 0 unknown = 0 posters = 0 ids = 0 requests = 0 errors = 0 retries = 0 }
  150. backfillLine = () => {
  151. b = backfillTotals
  152. return b.titles + '/' + backfillQueue.length + ' titles, adult=' + b.adult + ' notAdult=' + b.notAdult + ' unknown=' + b.unknown + ' posters=' + b.posters
  153. + ' ids=' + b.ids + ' requests=' + b.requests + ' errors=' + b.errors + ' retries=' + b.retries + ' seconds=' + ((now() - backfillAt) / 1000)
  154. }
  155. backfillTick = () => {
  156. if (backfillDone) { return null }
  157. t = now()
  158. if (backfillQueue == null) {
  159. backfillQueue = adultBackfillQueue()
  160. backfillAt = t
  161. console.log('adult backfill: start, ' + backfillQueue.length + ' titles without an adult flag (' + (now() - t) + ' ms to find them)')
  162. if (backfillQueue.length == 0) { backfillDone = true console.log('adult backfill: nothing to do') }
  163. return null
  164. }
  165. if (t < backfillNextAt) { return null }
  166. id = backfillQueue[backfillPos]
  167. backfillPos = backfillPos + 1
  168. r = backfillTitle(id)
  169. if (r.retry && (backfillTries[id] == null || backfillTries[id] < 2)) {
  170. backfillTries[id] = backfillTries[id] == null ? 1 : backfillTries[id] + 1
  171. q = backfillQueue
  172. q.push(id)
  173. backfillQueue = q
  174. backfillTotals.retries = backfillTotals.retries + 1
  175. } else {
  176. backfillTotals.titles = backfillTotals.titles + 1
  177. if (r.adult == true) { backfillTotals.adult = backfillTotals.adult + 1 } else if (r.adult == false) { backfillTotals.notAdult = backfillTotals.notAdult + 1 } else { backfillTotals.unknown = backfillTotals.unknown + 1 }
  178. }
  179. backfillTotals.posters = backfillTotals.posters + r.posters
  180. backfillTotals.ids = backfillTotals.ids + r.ids
  181. backfillTotals.requests = backfillTotals.requests + r.requests
  182. backfillTotals.errors = backfillTotals.errors + r.errors
  183. if (r.error != '') { console.log('adult backfill: ' + r.error) }
  184. if (r.adult != null) {
  185. refreshCatalogShow(id)
  186. searchTitleChanged(id)
  187. }
  188. took = now() - t
  189. if (took > 1500) { console.log('adult backfill: slow step, show ' + id + ', ' + took + ' ms') }
  190. backfillNextAt = now() + r.requests * msPerRequest
  191. finished = backfillPos >= backfillQueue.length
  192. if (finished || backfillPos % 25 == 0) { persistSync() }
  193. if (!finished && backfillTotals.titles > 0 && backfillTotals.titles % backfillLogEvery == 0 && !r.retry) { console.log('adult backfill: ' + backfillLine()) }
  194. if (finished) {
  195. backfillDone = true
  196. console.log('adult backfill done: ' + backfillLine())
  197. }
  198. return null
  199. }
  200. // ---- THE DETAILS REPAIR (tracker.worldapi.org#26, details.hl completeStep) ----------------------------------------
  201. // Titles the person pages added from a filmography (#16) are MINIMAL (no poster, seasons, ids, cast …), and (tracker#33, mission
  202. // 029) the old tracker's migrated rows were never synced (5,697 on the live copy, 691 series without seasons) — shows.hl
  203. // isIncomplete. Opening one completes it (components/show.hl); this job completes the rest in the background: at start it
  204. // collects every incomplete, non-adult title (the visibly reduced ones first, details.hl detailsRepairQueue) and does ONE per
  205. // step on the app's clock, like the adult backfill — a step is the daily sync's work for one title
  206. // (1–3 TMDB requests + poster + TVmaze), requests queued meanwhile are served between two steps; then a pause of 260 ms per
  207. // TMDB request + 550 ms per TVmaze request (pauseMsAfter: ≤ 40 / 10 s, ≤ 20 / 10 s). RESUMES after a restart (the queue is
  208. // what is still incomplete); TMDB 404 marks the title (`detailsCheck`), a passing failure goes to the back of the queue (at
  209. // most 2 more tries per start). Waits while the daily sync or the adult backfill runs. Persisted every 10 titles + at the end.
  210. // Log: start, every TRACKER_REPAIR_LOG_EVERY (100) titles, each failure, done. TRACKER_REPAIR=0 switches it off (off too
  211. // without TMDB_READ_TOKEN). TRACKER_REPAIR_FAST=1 (the gate, fake TMDB only): 20 ms pause instead.
  212. repairOn = env('TRACKER_REPAIR') != '0' && syncEnabled
  213. repairFast = env('TRACKER_REPAIR_FAST') == '1'
  214. repairLogEvery = env('TRACKER_REPAIR_LOG_EVERY') != null ? toNumber(env('TRACKER_REPAIR_LOG_EVERY')) : 100
  215. repairQueue = null
  216. repairPos = 0
  217. repairDone = false
  218. repairAt = 0
  219. repairNextAt = 0
  220. repairTries = {}
  221. repairTotals = { titles = 0 complete = 0 failed = 0 adult = 0 newSeasons = 0 newEpisodes = 0 posters = 0 cast = 0 requests = 0 tvmazeRequests = 0 retries = 0 }
  222. repairLine = () => {
  223. b = repairTotals
  224. return b.titles + '/' + repairQueue.length + ' titles, complete=' + b.complete + ' failed=' + b.failed + ' adult=' + b.adult + ' newSeasons=' + b.newSeasons + ' newEpisodes=' + b.newEpisodes
  225. + ' posters=' + b.posters + ' cast=' + b.cast + ' requests=' + b.requests + ' tvmazeRequests=' + b.tvmazeRequests + ' retries=' + b.retries + ' seconds=' + ((now() - repairAt) / 1000)
  226. }
  227. repairTick = () => {
  228. if (repairDone) { return null }
  229. t = now()
  230. if (repairQueue == null) {
  231. repairQueue = detailsRepairQueue()
  232. repairAt = t
  233. console.log('details repair: start, ' + repairQueue.length + ' incomplete titles (' + (now() - t) + ' ms to find them)')
  234. if (repairQueue.length == 0) { repairDone = true console.log('details repair: nothing to do') }
  235. return null
  236. }
  237. if (t < repairNextAt) { return null }
  238. id = repairQueue[repairPos]
  239. r = completeStep(id)
  240. took = now() - t
  241. if (took > 1500) { console.log('details repair: slow step, show ' + id + ', ' + took + ' ms') }
  242. if (r.error != '') { console.log('details repair: ' + r.error) }
  243. repairNextAt = now() + (repairFast ? 20 : pauseMsAfter(r))
  244. // a series takes several steps: the same title again next time
  245. if (!r.done && !r.retry) { return null }
  246. repairPos = repairPos + 1
  247. if (r.retry && (repairTries[id] == null || repairTries[id] < 2)) {
  248. repairTries[id] = repairTries[id] == null ? 1 : repairTries[id] + 1
  249. q = repairQueue
  250. q.push(id)
  251. repairQueue = q
  252. repairTotals.retries = repairTotals.retries + 1
  253. } else if (!r.skipped) {
  254. // done: its counts (a failed first step: the request alone)
  255. sum = r.sum
  256. repairTotals.titles = repairTotals.titles + 1
  257. if (r.adult == true) { repairTotals.adult = repairTotals.adult + 1 } else if (sum.steps == 0) { repairTotals.failed = repairTotals.failed + 1 } else { repairTotals.complete = repairTotals.complete + 1 }
  258. repairTotals.newSeasons = repairTotals.newSeasons + sum.newSeasons
  259. repairTotals.newEpisodes = repairTotals.newEpisodes + sum.newEpisodes
  260. repairTotals.posters = repairTotals.posters + sum.posters
  261. repairTotals.cast = repairTotals.cast + sum.cast
  262. repairTotals.requests = repairTotals.requests + (sum.steps == 0 ? r.requests : sum.requests)
  263. repairTotals.tvmazeRequests = repairTotals.tvmazeRequests + sum.tvmazeRequests
  264. }
  265. finished = repairPos >= repairQueue.length
  266. if (finished || repairPos % 10 == 0) { persistDetails() }
  267. if (!finished && !r.skipped && !r.retry && repairTotals.titles > 0 && repairTotals.titles % repairLogEvery == 0) { console.log('details repair: ' + repairLine()) }
  268. if (finished) {
  269. repairDone = true
  270. console.log('details repair done: ' + repairLine())
  271. }
  272. return null
  273. }
  274. // ---- THE TVMAZE STATUS BACKFILL (tracker#35, mission 030, backfill.hl tvmazeStatusTitle) — the details repair's second part ----
  275. // The page's status pill shows TVmaze's status when a series has one (fresher than TMDB's). The sync stores it whenever it merges
  276. // TVmaze's episodes (followed series, every completion); the series it never reached get it here: once the details repair is
  277. // done (same switch, TRACKER_REPAIR) every series with a TVmaze id and no tvmazeStatus, ONE TVmaze request per step, then 550 ms
  278. // (TVmaze: ≤ 20 / 10 s). RESUMES after a restart (the queue = what still has none); a 404 marks the series
  279. // (`tvmazeStatusCheck`), a passing failure goes to the back of the queue (at most 2 more tries per start). Waits while the daily
  280. // sync runs. Persisted every 25 series + at the end. Log: start, every TRACKER_REPAIR_LOG_EVERY series, done.
  281. statusQueue = null
  282. statusPos = 0
  283. statusDone = false
  284. statusAt = 0
  285. statusNextAt = 0
  286. statusTries = {}
  287. statusTotals = { series = 0 stored = 0 notFound = 0 requests = 0 errors = 0 retries = 0 }
  288. statusLine = () => {
  289. b = statusTotals
  290. return b.series + '/' + statusQueue.length + ' series, stored=' + b.stored + ' notFound=' + b.notFound + ' tvmazeRequests=' + b.requests + ' errors=' + b.errors + ' retries=' + b.retries + ' seconds=' + ((now() - statusAt) / 1000)
  291. }
  292. statusTick = () => {
  293. if (statusDone) { return null }
  294. t = now()
  295. if (statusQueue == null) {
  296. statusQueue = tvmazeStatusQueue()
  297. statusAt = t
  298. console.log('tvmaze status: start, ' + statusQueue.length + ' series without a TVmaze status (' + (now() - t) + ' ms to find them)')
  299. if (statusQueue.length == 0) { statusDone = true console.log('tvmaze status: nothing to do') }
  300. return null
  301. }
  302. if (t < statusNextAt) { return null }
  303. id = statusQueue[statusPos]
  304. statusPos = statusPos + 1
  305. r = tvmazeStatusTitle(id)
  306. if (r.retry && (statusTries[id] == null || statusTries[id] < 2)) {
  307. statusTries[id] = statusTries[id] == null ? 1 : statusTries[id] + 1
  308. q = statusQueue
  309. q.push(id)
  310. statusQueue = q
  311. statusTotals.retries = statusTotals.retries + 1
  312. } else {
  313. statusTotals.series = statusTotals.series + 1
  314. if (r.status != null) { statusTotals.stored = statusTotals.stored + 1 } else if (r.errors > 0) { statusTotals.notFound = statusTotals.notFound + 1 }
  315. }
  316. statusTotals.requests = statusTotals.requests + r.tvmazeRequests
  317. statusTotals.errors = statusTotals.errors + r.errors
  318. if (r.error != '') { console.log('tvmaze status: ' + r.error) }
  319. statusNextAt = now() + (repairFast ? 20 : pauseMsAfter(r))
  320. finished = statusPos >= statusQueue.length
  321. if (finished || statusPos % 25 == 0) { persistSync() }
  322. if (!finished && !r.retry && statusTotals.series > 0 && statusTotals.series % repairLogEvery == 0) { console.log('tvmaze status: ' + statusLine()) }
  323. if (finished) {
  324. statusDone = true
  325. console.log('tvmaze status done: ' + statusLine())
  326. }
  327. return null
  328. }
  329. // ---- THE KIND BACKFILL (tracker.worldapi.org#21, mission 068, backfill.hl kindTitle) ----------------------------------
  330. // Every TV title without a stored kind gets one: a title with a show genre (Reality / Talk / News) from the stored data (no
  331. // request), any other from TMDB's TV type (ONE request: GET /tv/<id>, then 260 ms pause). Starts once the adult backfill is
  332. // done (or off), waits while the daily sync runs, ONE title per step on the same clock. A title that becomes a SHOW moves from
  333. // /series to /shows at once (catalog.hl refreshCatalogShow). RESUMES after a restart (the queue = every TV title still without
  334. // a kind); a 404 stores the genres' answer + `kindCheck`; a passing failure goes to the back of the queue, at most 2 more tries
  335. // per start. Log: start, every TRACKER_KINDS_LOG_EVERY (500) titles, done. TRACKER_KINDS=0 switches it off; without
  336. // TMDB_READ_TOKEN it is off too (the lists still split by genre: shows.hl titleKind).
  337. kindsOn = env('TRACKER_KINDS') != '0' && syncEnabled
  338. kindsLogEvery = env('TRACKER_KINDS_LOG_EVERY') != null ? toNumber(env('TRACKER_KINDS_LOG_EVERY')) : 500
  339. kindQueue = null
  340. kindPos = 0
  341. kindDone = false
  342. kindAt = 0
  343. kindNextAt = 0
  344. kindTries = {}
  345. kindTotals = { titles = 0 series = 0 shows = 0 fromGenre = 0 moved = 0 requests = 0 errors = 0 retries = 0 }
  346. kindLine = () => {
  347. k = kindTotals
  348. return k.titles + '/' + kindQueue.length + ' titles, series=' + k.series + ' shows=' + k.shows + ' fromGenre=' + k.fromGenre + ' moved=' + k.moved
  349. + ' requests=' + k.requests + ' errors=' + k.errors + ' retries=' + k.retries + ' seconds=' + ((now() - kindAt) / 1000)
  350. }
  351. kindTick = () => {
  352. if (kindDone) { return null }
  353. t = now()
  354. if (kindQueue == null) {
  355. kindQueue = kindBackfillQueue()
  356. kindAt = t
  357. console.log('kind backfill: start, ' + kindQueue.length + ' TV titles without a kind (' + (now() - t) + ' ms to find them)')
  358. if (kindQueue.length == 0) { kindDone = true console.log('kind backfill: nothing to do') }
  359. return null
  360. }
  361. if (t < kindNextAt) { return null }
  362. id = kindQueue[kindPos]
  363. kindPos = kindPos + 1
  364. r = kindTitle(id)
  365. if (r.retry && (kindTries[id] == null || kindTries[id] < 2)) {
  366. kindTries[id] = kindTries[id] == null ? 1 : kindTries[id] + 1
  367. q = kindQueue
  368. q.push(id)
  369. kindQueue = q
  370. kindTotals.retries = kindTotals.retries + 1
  371. } else {
  372. kindTotals.titles = kindTotals.titles + 1
  373. if (r.kind == 'show') { kindTotals.shows = kindTotals.shows + 1 } else if (r.kind == 'series') { kindTotals.series = kindTotals.series + 1 }
  374. if (r.fromGenre) { kindTotals.fromGenre = kindTotals.fromGenre + 1 }
  375. }
  376. kindTotals.requests = kindTotals.requests + r.requests
  377. kindTotals.errors = kindTotals.errors + r.errors
  378. if (r.error != '') { console.log('kind backfill: ' + r.error) }
  379. // until now the genres decided (no show genre = series): only a title TMDB's type makes a SHOW changes its list
  380. if (r.kind == 'show' && !r.fromGenre) {
  381. refreshCatalogShow(id)
  382. kindTotals.moved = kindTotals.moved + 1
  383. }
  384. took = now() - t
  385. if (took > 1500) { console.log('kind backfill: slow step, show ' + id + ', ' + took + ' ms') }
  386. kindNextAt = now() + r.requests * msPerRequest
  387. finished = kindPos >= kindQueue.length
  388. if (finished || kindPos % 25 == 0) { persistSync() }
  389. if (!finished && kindTotals.titles > 0 && kindTotals.titles % kindsLogEvery == 0 && !r.retry) { console.log('kind backfill: ' + kindLine()) }
  390. if (finished) {
  391. kindDone = true
  392. console.log('kind backfill done: ' + kindLine())
  393. }
  394. return null
  395. }
  396. // ---- THE CREDITS JOB (tracker.worldapi.org#28, credits.hl creditsStep) ------------------------------------------------------
  397. // Every PUBLIC title (adult == false; adult/unknown are skipped) with a TMDB id gets its whole cast + crew once: at start (after
  398. // the adult backfill and the details repair are done) the job collects every such title without `creditsAt` and asks ONE per
  399. // step on the app's clock — one request (details + credits / aggregate_credits), then 260 ms (≤ 40 / 10 s); requests queued
  400. // meanwhile are served between two steps. Titles the details repair, the daily sync or an import already did carry `creditsAt`
  401. // and are not asked. RESUMES after a restart (the queue = what still has no credits); TMDB 404 / adult → `creditsCheck`, never
  402. // asked again; a passing failure goes to the back of the queue (at most 2 more tries per start). Waits while the daily sync
  403. // runs. Persisted (shows + people only) every 25 titles + at the end. Log: start, every TRACKER_CREDITS_LOG_EVERY (500) titles, failures, slow steps
  404. // (> 1.5 s), done. TRACKER_CREDITS=0 switches it off (off too without TMDB_READ_TOKEN). TRACKER_CREDITS_FAST=1 (the gate, fake
  405. // TMDB only): 20 ms pause instead.
  406. // MEMORY LIMIT: the runtime never frees what a fetch + JSON parse took (mission 061 measured ~6 MB more RSS per title on the real
  407. // data, 300 fetches of a 440 KB JSON = +2.7 GB in a 10-line script) — the whole job in one process would add ~35 GB. Before every
  408. // step the job reads its own RSS (/proc/self/status); above TRACKER_CREDITS_MAX_MB (16000) it PAUSES for this process (logged) and
  409. // goes on with what is left after the next restart (deploy, `docker restart`).
  410. creditsOn = env('TRACKER_CREDITS') != '0' && syncEnabled
  411. creditsFast = env('TRACKER_CREDITS_FAST') == '1'
  412. creditsLogEvery = env('TRACKER_CREDITS_LOG_EVERY') != null ? toNumber(env('TRACKER_CREDITS_LOG_EVERY')) : 500
  413. creditsQueueIds = null
  414. creditsPos = 0
  415. creditsDone = false
  416. creditsAt = 0
  417. creditsNextAt = 0
  418. creditsTries = {}
  419. creditsMaxMb = env('TRACKER_CREDITS_MAX_MB') != null ? toNumber(env('TRACKER_CREDITS_MAX_MB')) : 16000
  420. creditsTotals = { titles = 0 done = 0 failed = 0 cast = 0 crew = 0 people = 0 requests = 0 retries = 0 slowest = 0 }
  421. // this process' resident memory in MB (VmRSS), 0 when unknown
  422. rssMb = () => {
  423. if (!exists('/proc/self/status')) { return 0 }
  424. t = readFile('/proc/self/status')
  425. i = t != null ? t.indexOf('VmRSS:') : -1
  426. if (i < 0) { return 0 }
  427. kb = toNumber(t.slice(i + 6, t.indexOf('kB', i)).trim())
  428. return kb != null ? (kb - kb % 1024) / 1024 : 0
  429. }
  430. creditsLine = () => {
  431. b = creditsTotals
  432. return b.titles + '/' + creditsQueueIds.length + ' titles, done=' + b.done + ' failed=' + b.failed + ' cast=' + b.cast + ' crew=' + b.crew + ' people=' + b.people
  433. + ' requests=' + b.requests + ' retries=' + b.retries + ' slowestStepMs=' + b.slowest + ' seconds=' + ((now() - creditsAt) / 1000)
  434. }
  435. creditsTick = () => {
  436. if (creditsDone) { return null }
  437. t = now()
  438. if (creditsQueueIds == null) {
  439. creditsQueueIds = creditsQueue()
  440. creditsAt = t
  441. console.log('credits job: start, ' + creditsQueueIds.length + ' titles without credits (' + (now() - t) + ' ms to find them)')
  442. if (creditsQueueIds.length == 0) { creditsDone = true console.log('credits job: nothing to do') }
  443. return null
  444. }
  445. if (t < creditsNextAt) { return null }
  446. mb = rssMb()
  447. if (mb > creditsMaxMb) {
  448. creditsDone = true
  449. persistCredits()
  450. console.log('credits job: paused, RSS ' + mb + ' MB > TRACKER_CREDITS_MAX_MB ' + creditsMaxMb + ' — ' + (creditsQueueIds.length - creditsPos) + ' titles left for the next start; ' + creditsLine())
  451. return null
  452. }
  453. id = creditsQueueIds[creditsPos]
  454. creditsPos = creditsPos + 1
  455. r = creditsStep(id)
  456. took = now() - t
  457. if (took > creditsTotals.slowest) { creditsTotals.slowest = took }
  458. if (took > 1500) { console.log('credits job: slow step, show ' + id + ', ' + took + ' ms, cast=' + r.cast + ' crew=' + r.crew + ' people=' + r.people) }
  459. if (r.error != '') { console.log('credits job: ' + r.error) }
  460. creditsNextAt = now() + (creditsFast ? 20 : r.requests * msPerRequest)
  461. if (r.retry && (creditsTries[id] == null || creditsTries[id] < 2)) {
  462. creditsTries[id] = creditsTries[id] == null ? 1 : creditsTries[id] + 1
  463. q = creditsQueueIds
  464. q.push(id)
  465. creditsQueueIds = q
  466. creditsTotals.retries = creditsTotals.retries + 1
  467. } else if (!r.skipped) {
  468. creditsTotals.titles = creditsTotals.titles + 1
  469. if (r.error != '') { creditsTotals.failed = creditsTotals.failed + 1 } else { creditsTotals.done = creditsTotals.done + 1 }
  470. creditsTotals.cast = creditsTotals.cast + r.cast
  471. creditsTotals.crew = creditsTotals.crew + r.crew
  472. creditsTotals.people = creditsTotals.people + r.people
  473. }
  474. creditsTotals.requests = creditsTotals.requests + r.requests
  475. finished = creditsPos >= creditsQueueIds.length
  476. if (finished || creditsPos % 25 == 0) { persistCredits() }
  477. if (!finished && !r.skipped && !r.retry && creditsTotals.titles > 0 && creditsTotals.titles % creditsLogEvery == 0) { console.log('credits job: ' + creditsLine()) }
  478. if (finished) {
  479. creditsDone = true
  480. console.log('credits job done: ' + creditsLine())
  481. }
  482. return null
  483. }
  484. // ---- THE DUPLICATE MERGE (tracker.worldapi.org#31, mission 026, merge.hl) ----------------------------------------------------
  485. // The old tracker's duplicate titles (same type + TMDB id) become ONE record each — follows, watches, seasons, cast, credits and
  486. // timelines moved to the keeper, the others kept as tombstones whose slug and short id lead to it — and seasons that name a title
  487. // without being in its list are merged into their twin or linked, and (tracker#39) a season's double episodes into one (merge.hl
  488. // has the rules). On its own clock (every 0.1 s) ONE
  489. // item per tick (a duplicate group, or one title's stray seasons; no TMDB), so pages are served between two items. The TMDB jobs
  490. // below (daily sync, backfills, repair, credits, collections) wait until it is done: none of them works on a record that is about
  491. // to become a tombstone. RESUMES after a restart (the queue = what is still duplicated / stray). Persisted every 10 items and at
  492. // the end. Log: start, one line per tombstone / repaired title, done; with nothing to do one line. TRACKER_MERGE=0 switches it off.
  493. mergeOn = env('TRACKER_MERGE') != '0'
  494. mergeRun = { started = false done = !mergeOn at = 0 items = 0 slowest = 0 }
  495. mergeTick = () => {
  496. if (mergeRun.done) { return null }
  497. t = now()
  498. if (!mergeRun.started) {
  499. mergeRun.started = true
  500. mergeRun.at = t
  501. n = mergePrepare()
  502. st = mergeStats()
  503. console.log('merge: start, ' + st.groups + ' duplicate groups (' + st.records + ' records), ' + st.strayTitles + ' titles with stray seasons, ' + st.doubleSeasons + ' seasons with double episodes (' + st.ms + ' ms to find them)')
  504. if (n == 0) {
  505. mergeRun.done = true
  506. console.log('merge: nothing to do')
  507. }
  508. return null
  509. }
  510. r = mergeStep()
  511. mergeRun.items = mergeRun.items + 1
  512. took = now() - t
  513. if (took > mergeRun.slowest) { mergeRun.slowest = took }
  514. if (took > 1500) { console.log('merge: slow step, ' + took + ' ms') }
  515. if (r.done || mergeRun.items % 10 == 0) { persistMerge() }
  516. if (r.done) {
  517. mergeRun.done = true
  518. console.log('merge done: ' + mergeLine() + ' items=' + mergeRun.items + ' slowestStepMs=' + mergeRun.slowest + ' seconds=' + ((now() - mergeRun.at) / 1000))
  519. }
  520. return null
  521. }
  522. if (!mergeOn) { console.log('merge: off (TRACKER_MERGE=0)') }
  523. else {
  524. mergeClock = every(0.1)
  525. on mergeClock.tick(x) {
  526. mergeTick()
  527. return null
  528. }
  529. }
  530. // ONE clock for all five (a tick every 0.1 s): the daily sync's step once a second as before; the backfill's steps in
  531. // between, only while no daily run is going on; the details repair only when neither has work (then its TVmaze status part,
  532. // tracker#35); then the kind backfill (#21);
  533. // the credits job (#28) last
  534. clockOn = syncOn || backfillOn || repairOn || kindsOn || creditsOn
  535. clockTicks = 0
  536. if (syncOn) { console.log('tmdb sync: daily at ' + syncHour + ':00 UTC') } else { console.log('tmdb sync: off (' + (syncEnabled ? 'TRACKER_SYNC=0' : 'no TMDB_READ_TOKEN') + ')') }
  537. if (!backfillOn) { console.log('adult backfill: off (' + (syncEnabled ? 'TRACKER_BACKFILL=0' : 'no TMDB_READ_TOKEN') + ')') }
  538. if (!repairOn) { console.log('details repair: off (' + (syncEnabled ? 'TRACKER_REPAIR=0' : 'no TMDB_READ_TOKEN') + ')') }
  539. if (!creditsOn) { console.log('credits job: off (' + (syncEnabled ? 'TRACKER_CREDITS=0' : 'no TMDB_READ_TOKEN') + ')') }
  540. if (!kindsOn) { console.log('kind backfill: off (' + (syncEnabled ? 'TRACKER_KINDS=0' : 'no TMDB_READ_TOKEN') + ')') }
  541. if (clockOn) {
  542. syncClock = every(0.1)
  543. on syncClock.tick(x) {
  544. clockTicks = clockTicks + 1
  545. // tracker#31: not before the duplicate merge is done
  546. if (!mergeRun.done) { return null }
  547. busy = syncQueue.length > 0 || syncPlanning
  548. if (syncOn && clockTicks % 10 == 0) { syncTick() }
  549. free = !busy && syncQueue.length == 0 && !syncPlanning
  550. if (backfillOn && free && !backfillDone) { backfillTick() }
  551. else if (repairOn && free && (!backfillOn || backfillDone) && !repairDone) { repairTick() }
  552. else if (repairOn && free && (!backfillOn || backfillDone) && !statusDone) { statusTick() }
  553. else if (kindsOn && free && (!backfillOn || backfillDone) && (!repairOn || (repairDone && statusDone)) && !kindDone) { kindTick() }
  554. else if (creditsOn && free && (!backfillOn || backfillDone) && (!repairOn || (repairDone && statusDone)) && (!kindsOn || kindDone)) { creditsTick() }
  555. return null
  556. }
  557. }
  558. // ---- THE SHORT-ID BACKFILL (mission 060, tracker.worldapi.org#27, shortids.hl shortIdStep) ----------------------------
  559. // Every show and person without a short id gets one in the background: on its own clock (every 0.1 s) ONE batch per tick,
  560. // as many records as fit into TRACKER_SHORTID_BUDGET_MS (default 40 ms) — no TMDB, only the tables — so a page waits at
  561. // most one batch. The queue is built at start (`ensureShortIds`) from what is still missing = it resumes after a restart.
  562. // Persisted every 20 batches and at the end. Log: start, every TRACKER_SHORTID_LOG_EVERY (5000) records, done; with nothing
  563. // to do one line. TRACKER_SHORTIDS=0 switches it off (the gate's resume check).
  564. shortIdOn = env('TRACKER_SHORTIDS') != '0'
  565. shortIdBudget = env('TRACKER_SHORTID_BUDGET_MS') != null ? toNumber(env('TRACKER_SHORTID_BUDGET_MS')) : 40
  566. shortIdLogEvery = env('TRACKER_SHORTID_LOG_EVERY') != null ? toNumber(env('TRACKER_SHORTID_LOG_EVERY')) : 5000
  567. shortIdRun = { at = 0 batches = 0 assigned = 0 nextLog = 0 slowest = 0 slowestPersist = 0 done = false }
  568. shortIdTick = () => {
  569. if (shortIdRun.done) { return null }
  570. t = now()
  571. r = shortIdStep(shortIdBudget)
  572. took = now() - t
  573. shortIdRun.batches = shortIdRun.batches + 1
  574. shortIdRun.assigned = shortIdRun.assigned + r.assigned
  575. if (took > shortIdRun.slowest) { shortIdRun.slowest = took }
  576. if (r.done || shortIdRun.batches % 20 == 0) {
  577. tp = now()
  578. persistShortIds()
  579. if (now() - tp > shortIdRun.slowestPersist) { shortIdRun.slowestPersist = now() - tp }
  580. }
  581. if (!r.done && shortIdRun.assigned >= shortIdRun.nextLog) {
  582. console.log('short ids: ' + shortIdRun.assigned + ' assigned, ' + r.left + ' left, ' + ((now() - shortIdRun.at) / 1000) + ' s')
  583. shortIdRun.nextLog = shortIdRun.nextLog + shortIdLogEvery
  584. }
  585. if (r.done) {
  586. shortIdRun.done = true
  587. s = shortIdStats()
  588. console.log('short ids done: assigned=' + shortIdRun.assigned + ' oldKept=' + s.oldKept + ' batches=' + shortIdRun.batches + ' slowestBatchMs=' + shortIdRun.slowest + ' slowestPersistMs=' + shortIdRun.slowestPersist + ' seconds=' + ((now() - shortIdRun.at) / 1000))
  589. }
  590. return null
  591. }
  592. if (!shortIdOn) { console.log('short ids: backfill off (TRACKER_SHORTIDS=0), ' + shortIdsLeft() + ' records without one') }
  593. else if (shortIdsLeft() == 0) { console.log('short ids: nothing to do') }
  594. else {
  595. shortIdRun.at = now()
  596. shortIdRun.nextLog = shortIdLogEvery
  597. console.log('short ids: backfill start, ' + shortIdsLeft() + ' records, ' + shortIdBudget + ' ms per batch')
  598. shortIdClock = every(0.1)
  599. on shortIdClock.tick(x) {
  600. shortIdTick()
  601. return null
  602. }
  603. }
  604. // ---- THE COLLECTION SEED (mission 066, tracker.worldapi.org#19, collections.hl seedStep) ------------------------------------
  605. // TMDB's movie collections become timelines: ONE movie per step (its details; once per collection the collection's parts), on
  606. // its own 0.1 s clock like the adult backfill — a pause of 260 ms per TMDB request made (≤ 40 / 10 s). It WAITS while the daily
  607. // sync or the adult backfill runs (they share TMDB's limit and the backfill brings the adult flags it skips by); since the merge
  608. // (mission 070) also until the details repair, the kind backfill and the credits job are done (or paused) — the LAST job. The queue =
  609. // every non-adult movie without a check row, so it RESUMES after a restart and does nothing once all are checked. Persisted
  610. // every TRACKER_COLLECTIONS_PERSIST_EVERY (25) steps and at the end. Log: start, every TRACKER_COLLECTIONS_LOG_EVERY (500) movies, done.
  611. // TRACKER_COLLECTIONS=0 switches it off; without TMDB_READ_TOKEN it is off too.
  612. collectionsOn = env('TRACKER_COLLECTIONS') != '0' && syncEnabled
  613. collectionsLogEvery = env('TRACKER_COLLECTIONS_LOG_EVERY') != null ? toNumber(env('TRACKER_COLLECTIONS_LOG_EVERY')) : 500
  614. collectionsPersistEvery = env('TRACKER_COLLECTIONS_PERSIST_EVERY') != null ? toNumber(env('TRACKER_COLLECTIONS_PERSIST_EVERY')) : 25
  615. collectionRun = { at = 0 steps = 0 nextAt = 0 done = false started = false slowest = 0 }
  616. collectionTick = () => {
  617. if (collectionRun.done) { return null }
  618. // mission 070 (merge): also behind the details repair, the kind backfill and the credits job — one TMDB pacing at a time
  619. if (!mergeRun.done || syncQueue.length > 0 || syncPlanning || (backfillOn && !backfillDone) || (repairOn && (!repairDone || !statusDone)) || (kindsOn && !kindDone) || (creditsOn && !creditsDone)) { return null }
  620. t = now()
  621. if (!collectionRun.started) {
  622. collectionRun.started = true
  623. collectionRun.at = t
  624. n = seedPrepare()
  625. console.log('collections: start, ' + n + ' movies to check (' + (now() - t) + ' ms to find them)')
  626. if (n == 0) { collectionRun.done = true console.log('collections: nothing to do') }
  627. return null
  628. }
  629. if (t < collectionRun.nextAt) { return null }
  630. r = seedStep()
  631. if (r.done) {
  632. collectionRun.done = true
  633. seedPersist()
  634. console.log('collections done: ' + seedLine() + ' seconds=' + ((now() - collectionRun.at) / 1000) + ' slowestStepMs=' + collectionRun.slowest)
  635. return null
  636. }
  637. collectionRun.steps = collectionRun.steps + 1
  638. took = now() - t
  639. if (took > collectionRun.slowest) { collectionRun.slowest = took }
  640. if (r.error != '') { console.log('collections: ' + r.error) }
  641. if (took > 1500) { console.log('collections: slow step, ' + took + ' ms') }
  642. collectionRun.nextAt = now() + r.requests * msPerRequest
  643. if (collectionRun.steps % collectionsPersistEvery == 0) { seedPersist() }
  644. if (collectionRun.steps % collectionsLogEvery == 0) { console.log('collections: ' + seedLine() + ' seconds=' + ((now() - collectionRun.at) / 1000)) }
  645. return null
  646. }
  647. if (!collectionsOn) { console.log('collections: off (' + (syncEnabled ? 'TRACKER_COLLECTIONS=0' : 'no TMDB_READ_TOKEN') + ')') }
  648. else {
  649. collectionClock = every(0.1)
  650. on collectionClock.tick(x) {
  651. collectionTick()
  652. return null
  653. }
  654. }
  655. // ---- THE CURATED FRANCHISE SEED (tracker.worldapi.org#40, mission 034, franchiseseed.hl) --------------------------------------
  656. // data/franchises.json → franchises + timelines, movies AND series. The LAST start job: it waits until the merge, the daily sync,
  657. // the backfills, the details repair, the kind backfill, the credits job and the collection seed are done (or off) — the
  658. // collection seed's timelines are what the file's `collections` attach. Then on its own 0.1 s clock ONE step per tick: the next
  659. // missing title imported (the search's import, complete with cast + crew; its log line `search import: …`), then the pause the daily sync makes after the same
  660. // requests (≤ 40 TMDB / 10 s, ≤ 20 TVmaze / 10 s); the queue done, the build (no TMDB). RESUMES after a restart (the queue = the
  661. // titles still missing), IDEMPOTENT (nothing missing + nothing changed = no write). Without TMDB_READ_TOKEN it only builds from
  662. // what we have. Log: start, every import, every TRACKER_FRANCHISE_SEED_LOG_EVERY (25) imports, done.
  663. // TRACKER_FRANCHISE_SEED=0 switches it off; TRACKER_FRANCHISE_FILE another data file (the gate's).
  664. franchiseSeedOn = env('TRACKER_FRANCHISE_SEED') != '0'
  665. franchiseSeedLogEvery = env('TRACKER_FRANCHISE_SEED_LOG_EVERY') != null ? toNumber(env('TRACKER_FRANCHISE_SEED_LOG_EVERY')) : 25
  666. franchiseRun = { at = 0 steps = 0 nextAt = 0 done = false started = false slowest = 0 }
  667. franchiseSeedTick = () => {
  668. if (franchiseRun.done) { return null }
  669. if (!mergeRun.done || syncQueue.length > 0 || syncPlanning || (backfillOn && !backfillDone) || (repairOn && (!repairDone || !statusDone)) || (kindsOn && !kindDone) || (creditsOn && !creditsDone) || (collectionsOn && !collectionRun.done)) { return null }
  670. t = now()
  671. if (!franchiseRun.started) {
  672. franchiseRun.started = true
  673. franchiseRun.at = t
  674. n = franchiseSeedPrepare(syncEnabled)
  675. st = franchiseSeedStats()
  676. if (!st.file) {
  677. franchiseRun.done = true
  678. console.log('franchise seed: ' + st.error + ' — nothing seeded')
  679. return null
  680. }
  681. console.log('franchise seed: start, ' + st.franchises + ' franchises, ' + st.timelines + ' timelines, ' + st.titles + ' titles in the file — ' + st.have + ' we have, ' + n + ' to import, ' + st.missing + ' TMDB lacks (' + (now() - t) + ' ms)')
  682. return null
  683. }
  684. if (t < franchiseRun.nextAt) { return null }
  685. r = franchiseSeedStep()
  686. took = now() - t
  687. if (took > franchiseRun.slowest) { franchiseRun.slowest = took }
  688. if (r.error != '') { console.log('franchise seed: ' + r.error) }
  689. if (took > 1500) { console.log('franchise seed: slow step, ' + took + ' ms') }
  690. if (r.done) {
  691. franchiseRun.done = true
  692. console.log('franchise seed done: ' + franchiseSeedLine() + ' seconds=' + ((now() - franchiseRun.at) / 1000) + ' slowestStepMs=' + franchiseRun.slowest)
  693. return null
  694. }
  695. franchiseRun.steps = franchiseRun.steps + 1
  696. franchiseRun.nextAt = now() + pauseMsAfter(r)
  697. if (franchiseRun.steps % franchiseSeedLogEvery == 0) { console.log('franchise seed: ' + franchiseSeedLine() + ' seconds=' + ((now() - franchiseRun.at) / 1000)) }
  698. return null
  699. }
  700. if (!franchiseSeedOn) { console.log('franchise seed: off (TRACKER_FRANCHISE_SEED=0)') }
  701. else {
  702. if (!syncEnabled) { console.log('franchise seed: no TMDB_READ_TOKEN — builds from the titles we have, imports nothing') }
  703. franchiseClock = every(0.1)
  704. on franchiseClock.tick(x) {
  705. franchiseSeedTick()
  706. return null
  707. }
  708. }

Branches

Latest commits

  • 4ecc67b2tracker: STATUS/LOG for the t38 + t40 merge (gates 374/0, 32/0, 53/0, 229/0, 26/0, check-theme 0; live copy checks)mre
  • e5945d2fMerge t40 (tracker#40 curated franchises, Franchises menu, superseded collections) into main: deploy.sh lists all six gates (browser, kinds, franchises, pager, franchiseseed, check-theme); search.hl keeps #37's personPhotoOf + #40's importWithCredits; pager gate runs with TRACKER_FRANCHISE_SEED=0; gates 374/0, 32/0, 53/0, 229/0, 26/0, check-theme 0mre
  • b638e99dMerge t38 (tracker#38 pagination, #35 Returning/Airing label) into main: LOG/STATUS keep both sides; pager gate follows #37's /people (everyone, last updated first: seed updatedAt); gates pager 229/0, browser 374/0mre
  • f8ffa4dbtracker: report 032 + The Remaining + #39mre
  • 7565a863tracker: LOG timemre
  • b10f00c8tracker#39: double episodes — migrated episodes whose TMDB id TMDB replaced are adopted by their number in the sync (old id -> migratedTmdbId); merge.hl step 3 merges each season's doubles at start (keeper: most watches > synced > first; watches moved/parked; tombstones into mergedEpisodes, nothing deleted); tools/count-duplicate-episodes.hl; gate fixture + paths-m039; live copy 850 -> 0 in 64 s; gates 373/0, 32/0, 52/0mre
  • 8f1d4542tracker#40: superseded collections — a TMDB collection timeline whose titles are all in one curated timeline is hidden (supersededBy; kept: own page + editor finder), set by the collection seed when it makes one and by the curated build (lifted when the cover is gone); partly covered ones join that franchise; no second widget (First Contact: only Star Trek — Prime); gate franchiseseed 26/0, browser 365/0, kinds 32/0, franchises 53/0, check-theme 0; real copy 24 supersededmre
  • 9448d643tracker#35 follow-up (mission 033): TVmaze 'Running' is labelled 'Returning', or 'Airing' while a non-special episode of the two newest seasons is released within today +-7 days (data unchanged); gate fixtures Running/Airing/Aired + a special; browser 366/0, kinds 32/0, franchises 52/0, pager 229/0, check-theme 0mre
  • 7d4b293dtracker#40: "Franchises" in the main menu (desktop header after People, phone sidebar) → /franchises, marked on franchise and timeline pages; gates 365/0, 32/0, 53/0, 24/0, check-theme 0mre
  • 8751adb8tracker: report 032mre
  • 9bce1f65tracker mission 032: STATUS gate files + the hour-boundary flakemre
  • 718bfb89tracker#37 (mission 032): /people = everyone, last updated first (updatedAt stamped by the person fill; view built at boot, touched people first at once), photo + name tiles (person colour) with the /movies pagination, /people/<letter> removed; photo = our file, tmdbProfile, a cast/crew entry's profile (in-memory map at boot), else the new 'no photo' placeholder; new cast/crew/created_by people keep tmdbProfile; search people rows with the photo; /settings = the heading only; util.hl sortDesc starts from sorted runs (same result, 105k: 1.6 s -> 0.15 s); gates 369/0, 32/0, 52/0, check-theme 0; README/STATUS/LOGmre
  • 93dfb0batracker#40 (mission 034): the curated franchises — data/franchises.json (17 franchises, 31 timelines, 285 TMDB titles, movies + series, in-universe/release order, 12 TMDB collections attached); lib/franchiseseed.hl + jobs.hl franchiseSeedTick (last start job, imports missing titles via details.hl importWithCredits = the search's Add, one per step paced, then one build; franchiseseed.db: editor changes win, the creator's same-name franchise adopted / timeline left alone, 404 remembered, resumable, idempotent); timeline heads 'N titles · in-universe order' (orderKind) and wrap on a phone; series pages show the widget; new gate tests/franchiseseed.mjs (5th in deploy.sh), the others run with TRACKER_FRANCHISE_SEED=0; gates 365/0, 32/0, 52/0, 24/0, check-theme 0; real copy 196 imported, 0 failed, 7 min, restart unchanged=31mre
  • 03ec792ftracker#38 (mission 033): pagination goes exactly to the clicked page — tilelist read the clicked button's text after pagination.hl's own handler had rebuilt the buttons (real clicks only); now li.current, else the button's own text; new gate tests/pager.mjs (5 lists x 11 pages, 390/1280, real + script clicks, Back/Forward) 229/0; browser 365/0, kinds 32/0, franchises 52/0, check-theme 0mre
  • 96ba683adeploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the scriptmre
  • eb3b9205tracker: report 031mre
  • 9b5d2e89tracker mission 031: README (What it does, Test: four gates + the #32 checks, Files: theme/, new pages), STATUS (real copy, A/B load, how to repeat, open points), LOGmre
  • 39950e4ctracker#32 (mission 031): the WorldAPI theme (theme/ vendored verbatim from layouts.worldapi.org 85b5654; styles.hl inherits it: accent green-dark, type colours 1-6; own base/header rules, row lines, genre-pill and inverted-button frames removed, the season foldable keeps its line; check-theme 21 -> 0, 4th deploy gate; main actions class primary) and the #32 header (theme AppHeader/MainMenu/UserMenu/Sidebar/ContentFirst: desktop brand, search, Series|Shows|Movies|Genres|People, user icon with Unwatched..Settings, Logout; signed out the ident selector, phone the iD icon dropdown; phone menu in the sidebar overlay; marked entry by :has); /find -> /search/<q>, /genres, /people(/<letter>), /settings; main { ContentFirst { slot } } works around the hl:web one-line slot bug; gates 365/0, 32/0, 52/0, check-theme 0mre
  • a386dc92tracker: reports 029 + 030mre
  • 71e0fd7dtracker missions 029 + 030: README (What it does, Files, gate count), STATUS (real-copy numbers, how to repeat, open points), LOGmre