gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit9bce1f659bce1f65tracker mission 032: STATUS gate files + the hour-boundary flakemre9bce1f65/lib/shows.hl

24.1 KB

  1. // lib/shows.hl — READ-ONLY data access for a show's page (tracker.worldapi.org#4): shows, seasons,
  2. // episodes, persons, genres (storage/mpackdb/, migrated by tools/migrate.hl, tracker.worldapi.org#2).
  3. // Kept apart from watches.hl (the per-user watch state) and from components/show.hl (the page itself)
  4. // so /unwatched and /schedule (tickets #5/#6, "reuse, don't copy") can import the same functions.
  5. //
  6. // No declared index beyond the migration's own ['!oldId'] (opening a table with indexes it wasn't
  7. // created with is untested territory, hybriel#21 "opening a table rewrites its files") — a slug
  8. // lookup is a linear scan of ~9500 shows, cheap for one page load.
  9. import { MPackDB } from 'hl:mpackdb'
  10. import { exists } from 'hl:fs'
  11. import { storageDir, postersDir, hasId } from './util.hl'
  12. static genresTable = new MPackDB(file = storageDir + '/genres.db', primaryKey = '@id', indexes = ['!oldId'])
  13. static personsTable = new MPackDB(file = storageDir + '/persons.db', primaryKey = '@id', indexes = ['!oldId'])
  14. static showsTable = new MPackDB(file = storageDir + '/shows.db', primaryKey = '@id', indexes = ['!oldId'])
  15. static seasonsTable = new MPackDB(file = storageDir + '/seasons.db', primaryKey = '@id', indexes = ['!oldId'])
  16. static episodesTable = new MPackDB(file = storageDir + '/episodes.db', primaryKey = '@id', indexes = ['!oldId'])
  17. // the show with this urlSegment (slug), or null. tracker#28: by a slug → id map (one scan, at the first call) — the old scan of
  18. // every record per call (twice per show page) decoded every title's cast + crew: 82 ms per call on the live copy before the
  19. // credits, growing with them. A slug the map does not know (a title added since: import, filmography) costs one scan as before
  20. // and is remembered; slugs never change. (Flat static written key by key, like people.hl's maps.)
  21. // tracker#31 (mission 026): a MERGED title's slug (a tombstone's, below) and a keeper's former slug (`oldSlugs`) answer the
  22. // KEEPER — several records can share one slug (migrated duplicates did), so each slug has a rank: a live record's own slug (3)
  23. // beats a live record's former one (2) beats a tombstone's (1).
  24. static slugIds = {}
  25. static slugRank = {}
  26. static slugIdsBuilt = { yes = false }
  27. // ---- merged titles (tracker#31, mission 026, merge.hl) ----------------------------------------------------------------------
  28. // The old tracker left 68 titles as 2–6 records each (same type + TMDB id). The repair (merge.hl) keeps ONE record (the keeper)
  29. // and turns the others into TOMBSTONES — never deleted: `mergedInto` = the keeper's id, `mergedTmdbId` (their `tmdbId` is
  30. // null, so nothing looks them up by it), `mergedSeasons` (their `seasons` are empty). Every list skips them (isPublicTitle),
  31. // every job skips them, a tombstone's slug and short id lead to the keeper.
  32. static isMerged = (&show) => { return show != null && show.mergedInto != null }
  33. // the record a page shows for this one: the keeper of a tombstone (a chain is followed, at most 5 steps), else itself
  34. static liveShowOf = (&show) => {
  35. let s = show
  36. let n = 0
  37. while (s != null && s.mergedInto != null && n < 5) {
  38. s = showsTable.fetch(s.mergedInto)
  39. n = n + 1
  40. }
  41. return s
  42. }
  43. static holdsSlug = (&s, &slug) => { return s.urlSegment == slug || (s.oldSlugs != null && s.oldSlugs.includes(slug)) }
  44. // this record's slugs into the map (at the build, and by merge.hl after a merge changed a record)
  45. static noteSlugsOf = (&s) => {
  46. live = s.mergedInto == null
  47. mine = []
  48. if (s.urlSegment != null) { mine.push({ slug = s.urlSegment rank = live ? 3 : 1 }) }
  49. if (live && s.oldSlugs != null) { for (o of s.oldSlugs) { mine.push({ slug = o rank = 2 }) } }
  50. for (m of mine) {
  51. let cur = slugRank[m.slug]
  52. if (cur == null || m.rank >= cur || slugIds[m.slug] == s.id) {
  53. slugIds[m.slug] = s.id
  54. slugRank[m.slug] = m.rank
  55. }
  56. }
  57. return null
  58. }
  59. static ensureSlugIds = () => {
  60. if (!slugIdsBuilt.yes) {
  61. for (s of showsTable.find(null, null)) { noteSlugsOf(s) }
  62. slugIdsBuilt.yes = true
  63. }
  64. return true
  65. }
  66. static showBySlug = (&slug) => {
  67. if (slug == null || hlTypeName(slug) != 'String' || slug == '') { return null }
  68. ensureSlugIds()
  69. id = slugIds[slug]
  70. if (id != null) {
  71. hit = showsTable.fetch(id)
  72. if (hit != null && holdsSlug(hit, slug)) { return liveShowOf(hit) }
  73. }
  74. let found = null
  75. for (s of showsTable.find(null, null)) {
  76. if (holdsSlug(s, slug) && (found == null || (found.mergedInto != null && s.mergedInto == null))) { found = s }
  77. }
  78. if (found != null) {
  79. noteSlugsOf(found)
  80. return liveShowOf(found)
  81. }
  82. return null
  83. }
  84. // project.hl at boot: every slug that is not a live title's own any more (a tombstone's, a keeper's former one) → the keeper's
  85. // page, [{ slug, path }] — answered with a 301 (a component route cannot redirect; project.hl slugMoved asks `movedPathOf`)
  86. static movedPaths = {}
  87. static movedSlugs = () => {
  88. ensureSlugIds()
  89. out = []
  90. for (slug of slugRank.keys()) {
  91. if (slugRank[slug] < 3) {
  92. let keeper = liveShowOf(showsTable.fetch(slugIds[slug]))
  93. if (keeper != null && keeper.mergedInto == null && keeper.urlSegment != null && keeper.urlSegment != slug) {
  94. let to = titlePath(keeper)
  95. out.push({ slug = slug path = to })
  96. movedPaths['/movies/' + slug] = to
  97. movedPaths['/series/' + slug] = to
  98. }
  99. }
  100. }
  101. return out
  102. }
  103. static movedPathOf = (&path) => { return path != null ? movedPaths[path] : null }
  104. static genreById = (&id) => { return id == null ? null : genresTable.fetch(id) }
  105. // /genres/<genre> (mission 058): the genre with this urlSegment ('Action', 'Sci-Fi-Fantasy'), exact first, else ignoring case
  106. // — a scan of the genres table (27 rows)
  107. static genreBySlug = (&slug) => {
  108. if (slug == null || hlTypeName(slug) != 'String' || slug == '') { return null }
  109. lower = slug.toLowerCase()
  110. let loose = null
  111. for (g of genresTable.find(null, null)) {
  112. if (g.urlSegment == slug) { return g }
  113. if (loose == null && g.urlSegment != null && ('' + g.urlSegment).toLowerCase() == lower) { loose = g }
  114. }
  115. return loose
  116. }
  117. static personById = (&id) => { return id == null ? null : personsTable.fetch(id) }
  118. static seasonById = (&id) => { return id == null ? null : seasonsTable.fetch(id) }
  119. static showById = (&id) => { return id == null ? null : showsTable.fetch(id) }
  120. static episodeById = (&id) => { return id == null ? null : episodesTable.fetch(id) }
  121. // EVERY show / episode (tracker.worldapi.org#13, catalog.hl): read ONCE when the app starts, to build the public lists —
  122. // never per request
  123. static allShows = () => { return showsTable.find(null, null) }
  124. static allEpisodes = () => { return episodesTable.find(null, null) }
  125. // insertion sort, hand-written (no list sort(), hybriel#1) — a show has a handful of seasons at most
  126. static insertDesc = (&sorted, &s) => {
  127. out = []
  128. let inserted = false
  129. for (x of sorted) {
  130. if (!inserted && s.seasonNumber >= x.seasonNumber) { out.push(s) inserted = true }
  131. out.push(x)
  132. }
  133. if (!inserted) { out.push(s) }
  134. return out
  135. }
  136. static insertAsc = (&sorted, &e) => {
  137. out = []
  138. let inserted = false
  139. for (x of sorted) {
  140. if (!inserted && e.episodeNumber <= x.episodeNumber) { out.push(e) inserted = true }
  141. out.push(x)
  142. }
  143. if (!inserted) { out.push(e) }
  144. return out
  145. }
  146. // a show's seasons, latest (highest seasonNumber) first — creator: "all seasons in reverse order,
  147. // latest on top"
  148. static seasonsOfShow = (&show) => {
  149. let sorted = []
  150. for (id of show.seasons) {
  151. let s = seasonsTable.fetch(id)
  152. if (s != null) { sorted = insertDesc(sorted, s) }
  153. }
  154. return sorted
  155. }
  156. // a season's episodes, in episode-number order
  157. static episodesOfSeason = (&season) => {
  158. let sorted = []
  159. for (id of season.episodes) {
  160. let e = episodesTable.fetch(id)
  161. if (e != null) { sorted = insertAsc(sorted, e) }
  162. }
  163. return sorted
  164. }
  165. // ---- labels shared by every list (tracker.worldapi.org#8) -------------------------------------
  166. static pad2 = (&n) => {
  167. let s = '' + n
  168. while (s.length < 2) { s = '0' + s }
  169. return s
  170. }
  171. // an episode as `S01E01` (creator: "write it like that: S01E01") — /my/shows, /my/unwatched, /my/schedule
  172. static episodeCode = (&seasonNumber, &episodeNumber) => { return 'S' + pad2(seasonNumber) + 'E' + pad2(episodeNumber) }
  173. // the show's year: `year`, else the first 4 characters of `release` ('YYYY-MM-DD'; 197 migrated shows have
  174. // no year, a few of those an empty release) — null when neither gives one
  175. static showYear = (&show) => {
  176. if (show.year != null) { return '' + show.year }
  177. if (show.release != null && hlTypeName(show.release) == 'String' && show.release.length >= 4) { return show.release.slice(0, 4) }
  178. return null
  179. }
  180. // a show's title as every list shows it: `Doctor Who (2005)` (creator: so same-named shows can be told apart)
  181. static titleWithYear = (&show) => {
  182. y = showYear(show)
  183. return y != null ? show.title + ' (' + y + ')' : show.title
  184. }
  185. // ---- the description (tracker#18) ---------------------------------------------------------------
  186. // creator: "i put the summary in an own field for tmdb because some summaries i wanted to rewrite ... in that case the summary
  187. // has priority over maze or tmdb" — `summary` (the creator's own text, never written by the sync), else TMDB's `tmdbSummary`,
  188. // else TVmaze's `tvmazeSummary` (HTML stripped); '' when none
  189. static hasText = (&v) => { return v != null && hlTypeName(v) == 'String' && v.trim() != '' }
  190. static summaryOf = (&show) => {
  191. if (show == null) { return '' }
  192. if (hasText(show.summary)) { return show.summary }
  193. if (hasText(show.tmdbSummary)) { return show.tmdbSummary }
  194. if (hasText(show.tvmazeSummary)) { return show.tvmazeSummary }
  195. return ''
  196. }
  197. // ---- a series' status (tracker#35, mission 030) -----------------------------------------------------------------------
  198. // The page's status pill (components/show.hl) next to a series' or show's title: TVmaze's `tvmazeStatus` (Running, Ended, To Be
  199. // Determined, In Development — stored by the sync and backfill.hl's status backfill) when there is one — creator: "this was also
  200. // something tvmaze was better updated about" — else TMDB's `status` (Returning Series, In Production, Planned, Pilot, Ended,
  201. // Canceled). TVmaze has no "canceled": its Ended + TMDB's Canceled shows Canceled (the same state, TMDB's word says more).
  202. // { text, tone } — tone running | pending | ended | canceled | other (the pill's colour, styles.hl); text '' = no pill (a movie,
  203. // or no status known).
  204. static statusTones = { 'Running' = 'running' 'Returning Series' = 'running' 'To Be Determined' = 'pending' 'In Development' = 'pending'
  205. 'In Production' = 'pending' 'Planned' = 'pending' 'Pilot' = 'pending' 'Ended' = 'ended' 'Canceled' = 'canceled' }
  206. static statusOf = (&show) => {
  207. if (show == null || show.type == 'movie') { return { text = '' tone = '' } }
  208. let word = hasText(show.tvmazeStatus) ? show.tvmazeStatus : (hasText(show.status) ? show.status : '')
  209. if (word == 'Ended' && show.status == 'Canceled') { word = 'Canceled' }
  210. if (word == '') { return { text = '' tone = '' } }
  211. tone = statusTones[word]
  212. return { text = word == 'Returning Series' ? 'Returning' : word tone = tone != null ? tone : 'other' }
  213. }
  214. // ---- adult titles (mission 054) -----------------------------------------------------------------
  215. // `adult` on every title: true / false from TMDB, null = not known yet (the migrated rows; the app's backfill, backfill.hl
  216. // `backfillTitle`, asks TMDB). The PUBLIC lists (catalog.hl: homepage rows, /movies, /shows) and the search (search.hl) show
  217. // ONLY a title TMDB says is not adult — unknown counts as hidden. A title the user follows stays on /my/* and its page.
  218. // A merged tombstone (tracker#31) is never public.
  219. static isPublicTitle = (&show) => { return show != null && show.adult == false && show.mergedInto == null }
  220. // ---- incomplete titles (tracker.worldapi.org#26; details.hl completes them, credits.hl and dailysync.hl skip them) ------------
  221. // COMPLETE = TMDB's details answer went through this app once: completed (`detailsAt`, details.hl) or synced (`tmdbSync`, the
  222. // last step of sync.hl's sync — the daily run, a search import) — or given up on (`detailsCheck`: TMDB 404 / adult).
  223. // INCOMPLETE = every other title with a TMDB id: a filmography title (`minimal`, #26) until it is completed, an import whose
  224. // sync never finished, and (tracker#33, mission 029) the old tracker's MIGRATED rows that were never synced — #26 only looked
  225. // at `minimal`/`imported`, so they passed: live copy 2026-10-03, 5,697 non-adult titles (4,206 movies, 1,491 series), 691
  226. // series without a single season, 209 + 84 without a poster, 389 + 120 without genres (tools/count-incomplete.hl). Also a
  227. // movie with a TV answer's leftovers (below). What a title still lacks that a page shows: `missingParts`.
  228. static isIncomplete = (&s) => {
  229. return s != null && s.tmdbId != null && s.detailsCheck == null
  230. && ((s.detailsAt == null && (s.minimal == true || s.tmdbSync == null)) || hasTvLeftovers(s))
  231. }
  232. // tracker#33: what a title's page would miss — the parts a complete record has when TMDB has them: 'poster', 'summary',
  233. // 'genres', 'cast', 'ids' (no IMDb id), 'release', 'seasons' (a series without any). The repair does these titles first
  234. // (details.hl detailsRepairQueue); tools/count-incomplete.hl counts them. A complete title can still miss one — TMDB has none
  235. // (The Remaining, a 7-minute Finnish short: no poster, no IMDb id on TMDB).
  236. static missingParts = (&s) => {
  237. out = []
  238. if (s.image == null || s.image == '') { out.push('poster') }
  239. if (summaryOf(s) == '') { out.push('summary') }
  240. if (s.genres == null || s.genres.length == 0) { out.push('genres') }
  241. if (s.cast == null || s.cast.length == 0) { out.push('cast') }
  242. if (s.imdbId == null) { out.push('ids') }
  243. if (s.release == null || s.release == '') { out.push('release') }
  244. if (s.type != 'movie' && (s.seasons == null || s.seasons.length == 0)) { out.push('seasons') }
  245. return out
  246. }
  247. // mission 025 (report 021's "wrong TMDB id"): the #9 sync once asked TMDB for every followed title as `/tv/<tmdbId>` — a movie's
  248. // id is ANOTHER title there (fixed in mission 006: movies go to /movie/) and the TV title's overview, status and season/episode
  249. // counts were stored on the movie. On the real data only Star Trek: First Contact: its tmdbId 199 IS the movie (/movie/199),
  250. // tmdbSummary was TV 199's ("Kabuhayang Swak na Swak …"), status 'Ended', seasonsCount/episodesCount 0. The movie path never
  251. // writes the counts, so a movie that has them is such a record: the repair asks /movie/<id> again (withDetailsFields: overview →
  252. // tmdbSummary, status, …) and firstStep drops the counts — repaired once, then it no longer matches.
  253. static hasTvLeftovers = (&s) => { return s.type == 'movie' && (s.seasonsCount != null || s.episodesCount != null) }
  254. // ---- the kind of a title (tracker.worldapi.org#21, mission 068) ----------------------------------------------
  255. // A TV title (`type = 'series'`) is either a SERIES (TMDB's TV type Scripted, Miniseries, Documentary) or a SHOW (Reality,
  256. // Talk Show, News, Video — or one of our genres Reality / Talk / News, whatever the type). Stored on the title as `kind`
  257. // ('series' | 'show') and TMDB's type as `tmdbType`: by the kind backfill (backfill.hl `kindTitle`, one TMDB request per
  258. // title without a show genre), the daily sync and the search import. Until a title has `kind`, its genres decide (no
  259. // type known yet = series). Movies are `type = 'movie'` and have no kind.
  260. static showTmdbTypes = ['Reality', 'Talk Show', 'News', 'Video']
  261. static showGenreNames = ['Reality', 'Talk', 'News']
  262. static showGenreIdsOf = () => {
  263. out = {}
  264. for (g of genresTable.find(null, null)) { if (g.name != null && showGenreNames.includes('' + g.name)) { out[g.id] = true } }
  265. return out
  266. }
  267. // the genre ids that make a title a show — read once (the genres table never changes while the app runs)
  268. static showGenreIds = showGenreIdsOf()
  269. static hasShowGenre = (&genres) => {
  270. if (genres == null) { return false }
  271. for (g of genres) { if (showGenreIds[g] == true) { return true } }
  272. return false
  273. }
  274. // 'show' | 'series' from TMDB's type (null = not known) and the title's genre ids
  275. static kindOfTitle = (&tmdbType, &genres) => {
  276. if (hasShowGenre(genres)) { return 'show' }
  277. if (tmdbType != null && showTmdbTypes.includes('' + tmdbType)) { return 'show' }
  278. return 'series'
  279. }
  280. // 'movie' | 'series' | 'show' of a stored title
  281. static titleKind = (&show) => {
  282. if (show.type == 'movie') { return 'movie' }
  283. if (show.kind == 'show' || show.kind == 'series') { return show.kind }
  284. return kindOfTitle(show.tmdbType, show.genres)
  285. }
  286. // a title's own page: /movies/<slug>, /series/<slug>, /shows/<slug> (the old /shows/<slug> of a movie or series answers 301,
  287. // project.hl showsRoute)
  288. static titlePath = (&show) => {
  289. k = titleKind(show)
  290. return (k == 'movie' ? '/movies/' : (k == 'show' ? '/shows/' : '/series/')) + show.urlSegment
  291. }
  292. // `/shows/<slug>` (#21, mission 068; project.hl showsRoute): since the split only the game / reality / talk / news SHOWS live
  293. // there — the page a series or a movie answers with a 301 instead (its own page), as does a merged duplicate's slug or a
  294. // keeper's former one (tracker#31: the keeper's page); null = render the title page here (a show, or an unknown slug)
  295. static showsMovedPath = (&slug) => {
  296. show = showBySlug(slug)
  297. return show != null && (titleKind(show) != 'show' || show.urlSegment != slug) ? titlePath(show) : null
  298. }
  299. // tracker.worldapi.org#20: the type word of a page heading / list label and its colour class (styles.hl `type-*`)
  300. static kindWord = (&kind) => { return kind == 'movie' ? 'Movie' : (kind == 'show' ? 'Show' : 'Series') }
  301. static typeWordOf = (&show) => { return kindWord(titleKind(show)) }
  302. static typeClassOf = (&show) => { return 'type-word type-' + titleKind(show) }
  303. // the poster file name (oldId + the migrated extension) — null when either is missing; served at
  304. // /posters/<name> (images.hl), which falls back to a placeholder when the file itself isn't there
  305. // yet (the real poster files are not part of the mongo export, see the report's `open`)
  306. static posterName = (&show) => {
  307. if (show.oldId == null || show.image == null || show.image == '') { return null }
  308. return show.oldId + '.' + show.image
  309. }
  310. // the poster's URL for a LIST (/my/shows, tracker.worldapi.org#8): `/posters/<name>` only when the file really
  311. // is in storage/mpackdb/posters/ (images.hl serves the same folder), else the ONE placeholder URL
  312. // `/posters/none` — the real data has no poster files yet, and 128 different URLs all answering the same
  313. // placeholder were 128 requests per page load (the browser can't cache them as one)
  314. static posterUrlOf = (&show) => { return posterUrlOfName(posterName(show)) }
  315. static posterUrlOfName = (&name) => { return name != null && exists(postersDir + '/' + name) ? '/posters/' + name : '/posters/none' }
  316. // ---- slim per-title caches for the lists (tracker.worldapi.org#30, mission 025) ------------------------------------
  317. // /my/series took 4.4 s on a process that had run the first-start jobs (0.4 s fresh): every load fetched each followed title's
  318. // WHOLE record (cast + crew, up to 300 entries) and one episode per watch (11.7k fetches); /my/unwatched every season and
  319. // episode of every followed title. Each fetch decodes a new object, and with a big live heap (after the jobs) every byte
  320. // allocated feeds the byte-triggered GC. Now a list reads two small cached things per title:
  321. // - `cardOf(id)`: { id type kind title year titleYear href posterName } — what a row shows;
  322. // - `episodeRowsOf(id)`: every episode of the title as { id s e title release }, seasons latest first, episodes in order
  323. // (the same order as seasonsOfShow/episodesOfSeason);
  324. // - `episodeKeyOf(id)`: one episode as { show s e } — /my/series' last watched episode goes by the WATCHED episode's own
  325. // `show` (as before): migrated episodes the sync left outside the title's seasons (a duplicate season, e.g. Reacher S03 on
  326. // the real data) still count. project.hl warms every watched episode at boot.
  327. // Filled at the first ask (project.hl warms the followed titles at boot) and kept in sync by catalog.hl `refreshCatalogShow`,
  328. // which every writer of a title already calls after it changed one (daily sync, repair, kinds, adult backfill, imports):
  329. // it calls `refreshTitleCaches(show)`, which rebuilds the entries that exist. Cached values are only ever RETURNED from a
  330. // function (a `let x = map[k]` deep-copies the value; a return does not — measured: 3.7 ms per 20k-row copy).
  331. static cardCache = {}
  332. static episodeRowsCache = {}
  333. static episodeKeyCache = {}
  334. static cardFrom = (&show) => {
  335. y = showYear(show)
  336. return {
  337. id = show.id type = show.type kind = titleKind(show) title = show.title year = y != null ? y : ''
  338. titleYear = titleWithYear(show) href = titlePath(show) posterName = posterName(show)
  339. }
  340. }
  341. static cardOf = (&id) => {
  342. if (id == null) { return null }
  343. if (cardCache[id] != null) { return cardCache[id] }
  344. show = showsTable.fetch(id)
  345. if (show == null) { return null }
  346. cardCache[id] = cardFrom(show)
  347. return cardCache[id]
  348. }
  349. static episodeRowsFrom = (&show) => {
  350. out = []
  351. if (show.seasons == null) { return out }
  352. // loop names apart from the row's own `s`/`e` keys: inside an object literal a key set earlier shadows the variable
  353. for (sn of seasonsOfShow(show)) {
  354. for (ep of episodesOfSeason(sn)) {
  355. out.push({ id = ep.id s = ep.seasonNumber e = ep.episodeNumber title = ep.title != null ? ep.title : '' release = ep.release })
  356. }
  357. }
  358. return out
  359. }
  360. static episodeRowsOf = (&id) => {
  361. if (id == null) { return [] }
  362. if (episodeRowsCache[id] != null) { return episodeRowsCache[id] }
  363. show = showsTable.fetch(id)
  364. if (show == null) { return [] }
  365. episodeRowsCache[id] = episodeRowsFrom(show)
  366. return episodeRowsCache[id]
  367. }
  368. // an episode that is not stored is { show = null } (never fetched again)
  369. static episodeKeyOf = (&id) => {
  370. if (id == null) { return { show = null s = null e = null } }
  371. if (episodeKeyCache[id] != null) { return episodeKeyCache[id] }
  372. ep = episodesTable.fetch(id)
  373. episodeKeyCache[id] = ep != null ? { show = ep.show s = ep.seasonNumber e = ep.episodeNumber } : { show = null s = null e = null }
  374. return episodeKeyCache[id]
  375. }
  376. // a title changed (catalog.hl refreshCatalogShow): its cached entries again from the stored record; the episode keys of its
  377. // episodes from the new rows (numbers the sync changed). Keys of a title nobody follows (no rows cached) are not refreshed —
  378. // /my/series only reads followed titles, and warmTitleCaches covers every followed one at boot.
  379. static refreshTitleCaches = (&show) => {
  380. if (cardCache[show.id] != null) { cardCache[show.id] = cardFrom(show) }
  381. if (episodeRowsCache[show.id] != null) {
  382. episodeRowsCache[show.id] = episodeRowsFrom(show)
  383. sid = show.id
  384. for (r of episodeRowsOf(sid)) {
  385. if (episodeKeyCache[r.id] != null) { episodeKeyCache[r.id] = { show = sid s = r.s e = r.e } }
  386. }
  387. }
  388. return null
  389. }
  390. // project.hl at boot: the titles anyone follows and every watched episode, so the first /my/ load after a start is not the one
  391. // that fills them
  392. static warmTitleCaches = (&ids) => {
  393. let n = 0
  394. for (id of ids) {
  395. if (cardOf(id) != null) { episodeRowsOf(id) n = n + 1 }
  396. }
  397. return n
  398. }
  399. static warmEpisodeKeys = (&ids) => {
  400. for (id of ids) { episodeKeyOf(id) }
  401. return ids.length
  402. }
  403. // merge.hl (tracker#31): an episode that moved to another title — its key is read again at the next ask
  404. static forgetEpisodeKey = (&id) => {
  405. episodeKeyCache[id] = null
  406. return null
  407. }
  408. // ---- the show on other sites (tracker.worldapi.org#12) ------------------------------------------
  409. // the header's link icons: TMDB, IMDb, TheTVDB, TVmaze — ONLY for the ids the show has; a movie (`type = 'movie'`)
  410. // gets TMDB + IMDb. TheTVDB's id form is `/dereferrer/series/<id>` (checked 2026-10-01: it and the old
  411. // `?tab=series&id=` both 301 to the slug page); the others are the sites' own id URLs (they too 301 to a slug).
  412. static externalLinksOf = (&show) => {
  413. out = []
  414. movie = show.type == 'movie'
  415. if (hasId(show.tmdbId)) { out.push({ site = 'tmdb' label = 'TMDB' title = 'On TMDB' href = 'https://www.themoviedb.org/' + (movie ? 'movie/' : 'tv/') + show.tmdbId }) }
  416. if (hasId(show.imdbId)) { out.push({ site = 'imdb' label = 'IMDb' title = 'On IMDb' href = 'https://www.imdb.com/title/' + show.imdbId + '/' }) }
  417. if (!movie && hasId(show.tvdbId)) { out.push({ site = 'tvdb' label = 'TVDB' title = 'On TheTVDB' href = 'https://thetvdb.com/dereferrer/series/' + show.tvdbId }) }
  418. if (!movie && hasId(show.tvmzId)) { out.push({ site = 'tvmaze' label = 'TVmaze' title = 'On TVmaze' href = 'https://www.tvmaze.com/shows/' + show.tvmzId }) }
  419. return out
  420. }

Branches

Latest commits

  • 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
  • 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
  • d36ea6eatracker#34 + #35 (mission 030): Follow directly under the poster, as wide as the poster (show.hl, styles.hl); the status pill next to a series' title — TVmaze's status (new tvmazeStatus, stored by the sync's TVmaze merge) else TMDB's, TVmaze Ended + TMDB Canceled = Canceled, inverted (filled, dark text, no border), green running / yellow pending / red canceled / muted ended (shows.hl statusOf); the daily delta asks TVmaze's status of an unfollowed series TVmaze's change list names (dailysync.hl syncRunStep, sync.hl syncTvmazeStatus); the status backfill after the details repair (backfill.hl, jobs.hl statusTick; resumable, 550 ms per TVmaze request); gates 354/0, 32/0, 52/0mre
  • 7d7d4487tracker#33 (mission 029): reduced titles — every title TMDB's details never went through this app (no detailsAt, no tmdbSync) is incomplete (shows.hl isIncomplete; the old tracker's migrated rows passed #26's test: 5,697 non-adult on the live copy, 691 series without seasons); the repair job does the visibly reduced first (shows.hl missingParts), the page completes one on open; a title TMDB has no poster for (The Remaining) shows the placeholder; tools/count-incomplete.hl; gate fixtures stand for synced titles (tmdbSync), tests/seed-reduced.hl + #33 checks; gates 347/0, 32/0, 52/0mre
  • 661c2592tracker: report 028mre
  • 27c916fatracker mission 028: README ("Code order", the new file map), STATUS (counts before/after, tests, how to repeat, open), LOGmre
  • d924f398tracker mission 028: comments name the new files (sync.hl, dailysync.hl, backfill.hl, credits.hl, jobs.hl, images.hl …); tools/ref-params.py + tools/lambda-audit.py also scan lib/ (they globbed the root only), lambda-audit counts a plain `x = p` alias like `let x = p`mre
  • 2e89b968tracker mission 028 (code order) 5/5 let: `let` only where a variable is reassigned — 667 never-reassigned lets became plain declarations (project.hl, lib/, components/, tools/, tests/); kept: 264 in loop bodies (a plain declaration there is 'Cannot reassign' on the 2nd pass), 234 reassigned, 27 whose name is also a member/outer/free name (a plain write would rebind it); tools/let-audit.py decides and fixes (README 'Code order'); tests/realdata-m028.{sh,mjs} = the page-output diff on a real copy; gates 342/0, 32/0, 52/0, real-copy pages identicalmre
  • 54796ff2tracker mission 028 (code order) 4/5 thin faces + last copies: the show page's check/follow faces call lib/watches.hl toggleWatched / toggleSeasonWatched (seasonAllWatched moved there) and lib/follows.hl toggleFollowed; both logins (header selector face, /login/callback) share lib/users.hl userOfCode; todayStr/listOf copies in components and the export readers copied into tools/migrate.hl + tools/old-short-ids.hl now once (lib/util.hl, lib/export.hl); gates 342/0, 32/0, 52/0; old-short-ids output byte-identical, migrate output identicalmre
  • 06b078e3tracker mission 028 (code order) 3/5 project.hl is the map: config, routes, wiring and a feature → file index (914 → 258 lines); the background jobs (daily sync run, backfills, details repair, credits job, merge, short ids, collection seed) moved unchanged into lib/jobs.hl (a class: their state is reassigned every step, a static cannot be; one instance made after the server), the login callback into lib/users.hl, poster/photo serving into lib/images.hl, the /shows/<slug> rule into lib/shows.hl showsMovedPath; route handlers are thin wrappers; gates 342/0, 32/0, 52/0, real-copy pages identicalmre
  • 94716fd2tracker mission 028 (code order) 2/5 util + topics: lib/util.hl holds envOr, storageDir, postersDir, profilesDir, newId, hexDigits, todayStr, dateOr, textOr, hasId, listOr, firstOf, sortDesc once (were copied into up to 5 files); tmdbsync.hl split into tmdb.hl (TMDB/TVmaze requests), sync.hl (one title's sync), sync-helpers.hl, backfill.hl; details.hl split into details.hl, credits.hl, credits-helpers.hl (isIncomplete to shows.hl); search-helpers.hl (words, query, ranking, slugs); collections.hl (the TMDB collection seed, out of franchises.hl); deltasync.hl renamed dailysync.hl; no behaviour change: gates 342/0, 32/0, 52/0, real-copy pages identicalmre
  • 186079b0tracker mission 028 (code order) 1/5 move: every root .hl except project.hl into lib/ (styles.hl into components/), import paths only; gates 342/0, 32/0, 52/0; real-copy pages identicalmre
  • 4f47f181tracker: report 027mre
  • dc1d4be4tracker mission 027: Hybriel master 06617221 vendored (plugin allocator fixes 3a781359 + 413f60e4); real copy RSS through first-start jobs + 400 loads flat ~2.55 GB (190aa11d 2.3 -> 5.6 GB), page times <= 1.1x; gates 342/0, 32/0, 52/0mre