gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit96ba683a96ba683adeploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the scriptmre96ba683a/lib/people.hl

22.4 KB

  1. // lib/people.hl — THE PERSON PAGE's data (tracker.worldapi.org#16, components/person.hl `/person/<slug>`): a person by slug,
  2. // their facts and filmography, and the ONE-TIME fetch of their whole filmography from TMDB on the first visit. Creator:
  3. // "the movies come from artist scrolls. when one clicks on an artist that has no dataset yet the old version fetched that
  4. // artist and its entire bibilogrqphy so its profile was complete".
  5. //
  6. // personBySlug(slug) the person (slug = `urlSegment`) — a slug → id map built once (15k people, one scan)
  7. // personInfoOf(p) name, photo URL, born/died lines, bio
  8. // filmographyOf(p) their credits (`p.shows`): poster, title, year, role, kind — newest first, adult titles hidden
  9. // personFillStep(id) ONE step of the fetch, called again and again by the page until it answers `done`:
  10. // 1st call: GET <TMDB>/person/<tmdbId>?append_to_response=combined_credits (ONE request: details +
  11. // every cast/crew credit) + the photo (w185, like the posters); the person's facts are updated;
  12. // every next call stores the next `fillBatch` titles; the last one links the credits and marks
  13. // the person complete (`filmographyAt`, ms). hl:web serves one request at a time — between two
  14. // steps every other request is served, so a person with 300 credits never holds the server.
  15. //
  16. // COMPLETE = `filmographyAt` set: never fetched again (the daily sync may refresh followed people later — not built).
  17. // Migrated people are NOT complete (153 of them carry the old tracker's credits — kept, the fetch adds the rest).
  18. // A title we don't have → a MINIMAL show record (title, year, type, tmdbId, `adult`, overview, genres by TMDB id, language;
  19. // no seasons, no poster file; `minimal = true` — details.hl completes it when it is opened or by the repair job, tracker#26), shaped like search.hl importTitle's
  20. // (`oldId tmdb-<tv|movie>-<id>`, a free slug), indexed for the search and put into the public lists (catalog.hl).
  21. // The person's credits (`shows`, the migrated field): [{ show, character, posterPath, adult }] — `character` is the role
  22. // text (the characters, then crew jobs like "Director", " / " between them); `posterPath` = TMDB's, so the page can show
  23. // TMDB's small poster (w92, like search's web rows) until we have the file. ADULT (TMDB's flag, mission 054): a row is
  24. // shown only for a PUBLIC title (shows.hl `isPublicTitle`: `adult == false`, unknown hidden like the public lists) whose
  25. // credit is not adult either (mission 056 merge).
  26. // ONE PROCESS PER STORAGE (hybriel#21); new rows get self-assigned 16-hex ids (hybriel#113), like sync.hl.
  27. import { now } from 'hl:time'
  28. import { fetch } from 'hl:fetch'
  29. import { writeFile, mkDir, exists } from 'hl:fs'
  30. import { profilesDir, newId, textOr, listOr, sortDesc } from './util.hl'
  31. import { personsTable, showsTable, genresTable, showById, showYear, posterUrlOf, isPublicTitle, titlePath, typeWordOf, typeClassOf, liveShowOf } from './shows.hl'
  32. import { tmdbGet, tmdbImageBase } from './tmdb.hl'
  33. import { titleIdByTmdb, indexShow, slugOf, indexPerson, indexedPeople } from './search.hl'
  34. import { slugBaseOf } from './search-helpers.hl'
  35. import { refreshCatalogShow, pagesOf, pageNumberOf, pageSize } from './catalog.hl'
  36. import { claimShortId } from './shortids.hl'
  37. // titles stored per step (real data: see STATUS.md ticket #16 for the per-step time)
  38. static fillBatch = 40
  39. // ---- the person -------------------------------------------------------------------------------------------------
  40. static slugIndex = { built = false ids = {} }
  41. static ensureSlugIndex = () => {
  42. if (!slugIndex.built) {
  43. m = {}
  44. for (p of personsTable.find(null, null)) { if (p.urlSegment != null) { m[p.urlSegment] = p.id } }
  45. slugIndex.ids = m
  46. slugIndex.built = true
  47. }
  48. return true
  49. }
  50. static personBySlug = (&slug) => {
  51. if (slug == null || hlTypeName(slug) != 'String' || slug == '') { return null }
  52. ensureSlugIndex()
  53. id = slugIndex.ids[slug]
  54. return id == null ? null : personsTable.fetch(id)
  55. }
  56. static isComplete = (&p) => { return p.filmographyAt != null }
  57. // the page asks TMDB for this person: not complete yet, and TMDB knows them
  58. static needsFill = (&p) => { return !isComplete(p) && p.tmdbId != null }
  59. // the photo: /profiles/<oldId>.<ext> (images.hl) — only when the file is there (the migrated `image` = 'jpg'
  60. // of 129 people never came with a file)
  61. static profileName = (&p) => {
  62. if (p.oldId == null || p.image == null || p.image == '') { return null }
  63. return p.oldId + '.' + p.image
  64. }
  65. static photoUrlOf = (&p) => {
  66. name = profileName(p)
  67. return name != null && exists(profilesDir + '/' + name) ? '/profiles/' + name : ''
  68. }
  69. static monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
  70. // '1986-03-04' → '4 March 1986'; a bare year or anything else as it is
  71. static dateText = (&d) => {
  72. t = textOr(d)
  73. if (t == null) { return null }
  74. if (t.length < 10) { return t }
  75. m = toNumber(t.slice(5, 7))
  76. day = toNumber(t.slice(8, 10))
  77. if (m == null || day == null || m < 1 || m > 12) { return t }
  78. return day + ' ' + monthNames[m - 1] + ' ' + t.slice(0, 4)
  79. }
  80. // { name, photoUrl, born, died, bio } — every field a plain string ('' = none)
  81. static personInfoOf = (&p) => {
  82. born = dateText(p.birthDate)
  83. place = textOr(p.birthPlace)
  84. let bornText = ''
  85. if (born != null && place != null) { bornText = 'Born ' + born + ' in ' + place } else if (born != null) { bornText = 'Born ' + born } else if (place != null) { bornText = 'Born in ' + place }
  86. died = dateText(p.deathDate)
  87. return { name = p.name != null ? p.name : '' photoUrl = photoUrlOf(p) born = bornText died = died != null ? 'Died ' + died : ''
  88. bio = textOr(p.biography) != null ? p.biography : '' }
  89. }
  90. // ---- the filmography --------------------------------------------------------------------------------------------
  91. // the credits, one row per title (a title twice — the migrated credit and TMDB's — is ONE row, roles merged), newest
  92. // first by the title's release ('YYYY-MM-DD', else its year), undated last; only public titles (no adult/unknown)
  93. static filmographyOf = (&p) => {
  94. byShow = {}
  95. order = []
  96. for (c of listOr(p.shows)) {
  97. if (c != null && c.show != null) {
  98. let role = textOr(c.character)
  99. let prev = byShow[c.show]
  100. if (prev == null) {
  101. byShow[c.show] = { role = role != null ? role : '' posterPath = textOr(c.posterPath) adult = c.adult == true }
  102. order.push(c.show)
  103. } else {
  104. let x = prev
  105. if (role != null && !(' / ' + x.role + ' / ').includes(' / ' + role + ' / ')) { x.role = x.role == '' ? role : x.role + ' / ' + role }
  106. if (x.posterPath == null) { x.posterPath = textOr(c.posterPath) }
  107. if (c.adult == true) { x.adult = true }
  108. byShow[c.show] = x
  109. }
  110. }
  111. }
  112. list = []
  113. listed = {}
  114. for (sid of order) {
  115. let c = byShow[sid]
  116. // tracker#31: a credit on a merged tombstone is the keeper's (merge.hl repoints them; a keeper listed once)
  117. let s = liveShowOf(showById(sid))
  118. if (isPublicTitle(s) && !c.adult && listed[s.id] != true) {
  119. listed[s.id] = true
  120. let y = showYear(s)
  121. let release = textOr(s.release)
  122. let key = release != null && release.length >= 4 ? release : (y != null ? y : '')
  123. let poster = posterUrlOf(s)
  124. if (poster == '/posters/none' && c.posterPath != null) { poster = tmdbImageBase + '/w92' + c.posterPath }
  125. list.push({ key = key id = s.id title = s.title year = y != null ? y : '' href = titlePath(s) posterUrl = poster
  126. role = c.role typeLabel = typeWordOf(s) typeClass = typeClassOf(s) })
  127. }
  128. }
  129. out = []
  130. undated = []
  131. for (r of sortDesc(list)) { if (r.key == '') { undated.push(r) } else { out.push(r) } }
  132. for (r of undated) { out.push(r) }
  133. return out
  134. }
  135. // ---- the fetch ------------------------------------------------------------------------------------------------
  136. // person id → { items, pos, credits, added, requests, started, steps } while a fetch is under way (in memory: a restart
  137. // loses it — the titles stored so far are found again by TMDB id, nothing is duplicated)
  138. static jobs = {}
  139. // TMDB genre id → ours (our genres carry TMDB's id)
  140. static genreMap = { built = false ids = {} }
  141. static genreIdsOfTmdb = (&tmdbIds) => {
  142. if (!genreMap.built) {
  143. m = {}
  144. for (g of genresTable.find(null, null)) { if (g.tmdbId != null) { m['' + g.tmdbId] = g.id } }
  145. genreMap.ids = m
  146. genreMap.built = true
  147. }
  148. out = []
  149. for (t of listOr(tmdbIds)) {
  150. let id = genreMap.ids['' + t]
  151. if (id != null && !out.includes(id)) { out.push(id) }
  152. }
  153. return out
  154. }
  155. // TMDB's combined_credits → one item per title (cast AND crew of the same title merged), TV + movies only
  156. static creditItems = (&cc) => {
  157. byKey = {}
  158. order = []
  159. all = []
  160. if (cc != null) {
  161. for (c of listOr(cc.cast)) { all.push({ credit = c role = textOr(c.character) }) }
  162. for (c of listOr(cc.crew)) { all.push({ credit = c role = textOr(c.job) }) }
  163. }
  164. for (a of all) {
  165. let c = a.credit
  166. let kind = c.media_type
  167. if ((kind == 'tv' || kind == 'movie') && c.id != null && hlTypeName(c.id) == 'Number') {
  168. let k = kind + ':' + c.id
  169. let known = byKey[k]
  170. if (known == null) {
  171. let name = kind == 'tv' ? textOr(c.name) : textOr(c.title)
  172. if (name != null) {
  173. byKey[k] = { kind = kind tmdbId = c.id title = name release = textOr(kind == 'tv' ? c.first_air_date : c.release_date)
  174. overview = textOr(c.overview) language = textOr(c.original_language) genreIds = listOr(c.genre_ids)
  175. posterPath = textOr(c.poster_path) adult = c.adult == true role = a.role != null ? a.role : '' }
  176. order.push(k)
  177. }
  178. } else if (a.role != null && !(' / ' + known.role + ' / ').includes(' / ' + a.role + ' / ')) {
  179. let x = known
  180. x.role = x.role == '' ? a.role : x.role + ' / ' + a.role
  181. byKey[k] = x
  182. }
  183. }
  184. }
  185. out = []
  186. for (k of order) { out.push(byKey[k]) }
  187. return out
  188. }
  189. // the photo: w185 → storage/mpackdb/profiles/<oldId>.<ext> — { requests, image, tmdbProfile, failed }
  190. static syncProfile = (&p, profilePath) => {
  191. out = { requests = 0 image = p.image tmdbProfile = p.tmdbProfile failed = null }
  192. if (textOr(profilePath) == null || p.oldId == null) { return out }
  193. parts = profilePath.split('.')
  194. ext = parts[parts.length - 1].toLowerCase()
  195. if (ext != 'jpg' && ext != 'jpeg' && ext != 'png' && ext != 'webp') { return out }
  196. file = profilesDir + '/' + p.oldId + '.' + ext
  197. if (exists(file) && p.tmdbProfile == profilePath && p.image == ext) { return out }
  198. out.requests = 1
  199. r = fetch(tmdbImageBase + '/w185' + profilePath, { headers = { 'user-agent' = 'tracker.worldapi.org (person page)' } timeoutMs = 20000 })
  200. if (r == null || r.status != 200 || r.body == null || r.body.length == 0) {
  201. out.failed = 'photo ' + profilePath + ': ' + (r == null ? 'no answer' : 'HTTP ' + r.status)
  202. return out
  203. }
  204. mkDir(profilesDir)
  205. writeFile(file, toBytes(r.body), 420)
  206. out.image = ext
  207. out.tmdbProfile = profilePath
  208. return out
  209. }
  210. // step 1: TMDB's person + credits; the facts (a TMDB value that is empty never overwrites ours) and the photo
  211. static startFill = (p) => {
  212. t0 = now()
  213. d = tmdbGet('/person/' + p.tmdbId + '?append_to_response=combined_credits')
  214. if (d.failed != null) { return { error = 'TMDB: ' + d.failed } }
  215. items = creditItems(d.combined_credits)
  216. photo = syncProfile(p, d.profile_path)
  217. x = p
  218. if (textOr(d.biography) != null) { x.biography = d.biography }
  219. if (textOr(d.birthday) != null) { x.birthDate = d.birthday }
  220. if (textOr(d.deathday) != null) { x.deathDate = d.deathday }
  221. if (textOr(d.place_of_birth) != null) { x.birthPlace = d.place_of_birth }
  222. if (textOr(x.imdbId) == null && textOr(d.imdb_id) != null) { x.imdbId = d.imdb_id }
  223. if (d.adult != null) { x.adult = d.adult == true }
  224. x.image = photo.image
  225. x.tmdbProfile = photo.tmdbProfile
  226. if (personsTable.update(x.id, x) == null) { return { error = 'could not store the person: ' + personsTable.lastError() } }
  227. if (photo.failed != null) { console.log('person fill: ' + p.name + ': ' + photo.failed) }
  228. jobs[p.id] = { items = items pos = 0 credits = [] added = 0 requests = 1 + photo.requests started = t0 steps = 1 tmdbMs = now() - t0 }
  229. return { done = false pos = 0 total = items.length }
  230. }
  231. // a title we don't have: the minimal record (shape: search.hl importTitle) → its id, or null
  232. static addMinimalTitle = (&cr, &pid, pname) => {
  233. kindType = cr.kind == 'tv' ? 'series' : 'movie'
  234. rel = cr.release
  235. yr = rel != null && rel.length >= 4 ? toNumber(rel.slice(0, 4)) : null
  236. slug = slugOf(cr.title, cr.tmdbId)
  237. record = {
  238. id = newId() title = cr.title summary = null tmdbSummary = cr.overview tmdbId = cr.tmdbId
  239. language = cr.language type = kindType release = rel year = yr image = null
  240. urlSegment = slug episodesCount = null homepage = null imdbId = null seasonsCount = null
  241. status = null tagline = null tvdbId = null tvmzId = null genres = genreIdsOfTmdb(cr.genreIds)
  242. cast = [{ person = pid character = cr.role actor = pname }] seasons = [] oldId = 'tmdb-' + cr.kind + '-' + cr.tmdbId
  243. adult = cr.adult imported = now() minimal = true
  244. }
  245. // mission 060: its short id (shortids.hl — unique across shows and persons)
  246. record.shortId = claimShortId('show', record.id, record.oldId)
  247. if (showsTable.put(record) == null) {
  248. console.log('person fill: "' + cr.title + '" not stored: ' + showsTable.lastError())
  249. return null
  250. }
  251. indexShow(record)
  252. refreshCatalogShow(record.id)
  253. return record.id
  254. }
  255. // every next step: the next `fillBatch` titles; the last one links the credits and marks the person complete
  256. static fillStep = (p, jobIn) => {
  257. job = jobIn
  258. total = job.items.length
  259. let end = job.pos + fillBatch
  260. if (end > total) { end = total }
  261. credits = job.credits
  262. let added = job.added
  263. pid = p.id
  264. pname = p.name
  265. let i = job.pos
  266. while (i < end) {
  267. let item = job.items[i]
  268. let sid = titleIdByTmdb(item.kind == 'tv' ? 'series' : 'movie', item.tmdbId)
  269. if (sid == null) {
  270. sid = addMinimalTitle(item, pid, pname)
  271. if (sid != null) { added = added + 1 }
  272. }
  273. if (sid != null) { credits.push({ show = sid character = item.role posterPath = item.posterPath adult = item.adult }) }
  274. i = i + 1
  275. }
  276. job.pos = end
  277. job.credits = credits
  278. job.added = added
  279. job.steps = job.steps + 1
  280. jobs[pid] = job
  281. if (end < total) { return { done = false pos = end total = total } }
  282. // done: the credits (+ the migrated ones TMDB no longer lists), complete
  283. have = {}
  284. all = []
  285. for (c of credits) { have[c.show] = true all.push(c) }
  286. for (c of listOr(p.shows)) { if (c != null && c.show != null && have[c.show] != true) { all.push(c) } }
  287. x = p
  288. x.shows = all
  289. x.filmographyAt = now()
  290. if (personsTable.update(x.id, x) == null) { return { error = 'could not store the filmography: ' + personsTable.lastError() } }
  291. personsTable.persist()
  292. showsTable.persist()
  293. jobs[pid] = null
  294. console.log('person fill: ' + pname + ' (tmdb ' + p.tmdbId + ') credits=' + total + ' added=' + added + ' requests=' + job.requests + ' steps=' + job.steps + ' tmdbMs=' + job.tmdbMs + ' ms=' + (now() - job.started))
  295. return { done = true pos = total total = total added = added }
  296. }
  297. // one step for the person with this id: { done, pos, total } or { error }
  298. static personFillStep = (&personId) => {
  299. p = personsTable.fetch(personId)
  300. if (p == null) { return { error = 'no such person' } }
  301. if (isComplete(p)) { return { done = true } }
  302. if (p.tmdbId == null) { return { error = 'TMDB does not know this person' } }
  303. job = jobs[personId]
  304. if (job == null) { return startFill(p) }
  305. return fillStep(p, job)
  306. }
  307. // ---- people from a title's cast (tracker#26, details.hl completeStep) ------------------------------------------
  308. // TMDB person id → our person id, built once (15k people, one scan), kept up to date by castPersonId
  309. // (flat statics, written key by key like search.hl's haveTmdb: `let m = …ids` would copy the whole map — plain data
  310. // deep-copies on assignment)
  311. static personTmdbBuilt = { yes = false }
  312. static personTmdbIds = {}
  313. static personIdByTmdb = (&tmdbId) => {
  314. if (!personTmdbBuilt.yes) {
  315. for (p of personsTable.find(null, null)) { if (p.tmdbId != null) { personTmdbIds['' + p.tmdbId] = p.id } }
  316. personTmdbBuilt.yes = true
  317. }
  318. return personTmdbIds['' + tmdbId]
  319. }
  320. // a free person slug: "Maya-Rudolph", taken → "-2", … (the migrated people's form)
  321. static personSlugOf = (&name, &tmdbId) => {
  322. ensureSlugIndex()
  323. base = slugBaseOf(name, 'person-' + tmdbId)
  324. if (slugIndex.ids[base] == null) { return base }
  325. let n = 2
  326. while (slugIndex.ids[base + '-' + n] != null) { n = n + 1 }
  327. return base + '-' + n
  328. }
  329. // how many people castPersonId added since the start (details.hl counts a title's new people by the difference, tracker#28)
  330. static castPeopleAdded = { n = 0 }
  331. static castPeopleCount = () => { return castPeopleAdded.n }
  332. // our person for one cast entry of TMDB ({ tmdbId, name, character, gender }) — the one we have by TMDB id, else a NEW
  333. // person (name, tmdbId, a free slug, this one credit; not complete: their page fetches the rest on the first visit like any
  334. // migrated person). Answers the id, or null when it could not be stored. Also a CREW person (tracker#28: `character` = the
  335. // job, "Director").
  336. static castPersonId = (&c, &showId) => {
  337. have = personIdByTmdb(c.tmdbId)
  338. if (have != null) { return have }
  339. record = { id = newId() name = c.name tmdbId = c.tmdbId urlSegment = personSlugOf(c.name, c.tmdbId) oldId = 'tmdb-person-' + c.tmdbId
  340. gender = c.gender image = null tmdbProfile = null adult = false birthDate = null birthPlace = null deathDate = null imdbId = null
  341. shows = showId != null ? [{ show = showId character = c.character }] : [] added = now() }
  342. // mission 062 (tracker#27 for #26/#28): every person the app creates gets its short id at once (shortids.hl)
  343. record.shortId = claimShortId('person', record.id, record.oldId)
  344. if (personsTable.put(record) == null) {
  345. console.log('details: person "' + c.name + '" not stored: ' + personsTable.lastError())
  346. return null
  347. }
  348. personTmdbIds['' + c.tmdbId] = record.id
  349. slugIndex.ids[record.urlSegment] = record.id
  350. indexPerson(record)
  351. castPeopleAdded.n = castPeopleAdded.n + 1
  352. return record.id
  353. }
  354. // ---- GUEST STARS (mission 062): a series' guests are NOT person records — details.hl stores them on the title ({ tmdbId, actor,
  355. // character, profile, episodes, guest }, `person` only when we have them already). 160k people (most of them one-episode guests)
  356. // cost 3.3 GB of RSS at boot (w061). A guest's link is `/person/tmdb/<tmdbId>?show=<show id>` (project.hl guestRoute): the FIRST
  357. // open creates the person (name + role from that title's guest entry; without one — an old link — TMDB's /person/<id>), with its
  358. // short id, then the person page fills it like any other.
  359. static guestOf = (&showId, &tmdbId) => {
  360. s = showId != null && hlTypeName(showId) == 'String' && showId != '' ? showsTable.fetch(showId) : null
  361. if (s == null) { return null }
  362. for (c of listOr(s.cast)) { if (c != null && c.tmdbId == tmdbId && textOr(c.actor) != null) { return c } }
  363. return null
  364. }
  365. // our person for this TMDB person (created now when we have none) → { id, created } or { error }
  366. static guestPersonId = (tmdbId, showId) => {
  367. have = personIdByTmdb(tmdbId)
  368. if (have != null) { return { id = have created = false } }
  369. g = guestOf(showId, tmdbId)
  370. let c = null
  371. let inShow = null
  372. if (g != null) {
  373. c = { tmdbId = tmdbId name = g.actor character = g.character gender = null }
  374. inShow = showId
  375. } else {
  376. d = tmdbGet('/person/' + tmdbId)
  377. if (d.failed != null) { return { error = 'TMDB: ' + d.failed } }
  378. if (textOr(d.name) == null || d.adult == true) { return { error = 'no such person' } }
  379. c = { tmdbId = tmdbId name = d.name character = null gender = d.gender }
  380. }
  381. pid = castPersonId(c, inShow)
  382. if (pid == null) { return { error = 'could not store the person' } }
  383. personsTable.persist()
  384. console.log('guest opened: ' + c.name + ' (tmdb ' + tmdbId + ') → new person ' + pid + (inShow != null ? ' from show ' + inShow : ' from TMDB'))
  385. return { id = pid created = true }
  386. }
  387. // ---- /people (tracker#32, the main menu's People): everyone we have, by the first letter of the name -------------------------
  388. // From the search index (search.hl, built at boot — no table scan): `/people` lists the letters with how many, `/people/<letter>`
  389. // that letter's people A–Z, 24 per page (catalog.hl's paging) (`other` = names that start with no letter a–z). Each letter's list is sorted on its
  390. // first visit and kept for the process (a person added later shows after the next start; the search finds them at once).
  391. static peopleLists = { built = false letters = {} sorted = {} }
  392. static letterKeys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'other']
  393. static letterOf = (&text) => {
  394. c = text != null && text.length > 0 ? text.charAt(0) : ''
  395. return c >= 'a' && c <= 'z' && c.length == 1 ? c : 'other'
  396. }
  397. static ensurePeopleLists = () => {
  398. if (peopleLists.built) { return true }
  399. peopleLists.built = true
  400. for (k of letterKeys) { peopleLists.letters[k] = [] }
  401. for (e of indexedPeople()) { peopleLists.letters[letterOf(e.text)].push({ id = e.id key = e.text }) }
  402. return true
  403. }
  404. // [{ letter, label, href, count, cls }] for the letters that have people; `at` (the page's letter) is marked `current`
  405. static peopleLetters = (&at) => {
  406. ensurePeopleLists()
  407. out = []
  408. for (k of letterKeys) {
  409. let n = peopleLists.letters[k].length
  410. if (n > 0) { out.push({ letter = k label = k == 'other' ? '#' : k.toUpperCase() href = '/people/' + k count = n cls = k == at ? 'letter-link current' : 'letter-link' }) }
  411. }
  412. return out
  413. }
  414. static isPeopleLetter = (&k) => { return k != null && hlTypeName(k) == 'String' && letterKeys.includes(k) }
  415. static peopleCount = (&k) => {
  416. ensurePeopleLists()
  417. return isPeopleLetter(k) ? peopleLists.letters[k].length : 0
  418. }
  419. // one page of a letter: { page, pages, tiles } — a tile like the title grids' (components/tilelist.hl): photo, name, no year
  420. static peopleOfLetter = (&k, &raw) => {
  421. ensurePeopleLists()
  422. if (!isPeopleLetter(k)) { return { page = 1 pages = 1 tiles = [] } }
  423. if (peopleLists.sorted[k] == null) {
  424. desc = sortDesc(peopleLists.letters[k])
  425. asc = []
  426. let i = desc.length - 1
  427. while (i >= 0) { asc.push(desc[i]) i = i - 1 }
  428. peopleLists.sorted[k] = asc
  429. }
  430. list = peopleLists.sorted[k]
  431. pages = pagesOf(list.length)
  432. page = pageNumberOf(raw, pages)
  433. tiles = []
  434. for (x of list.slice((page - 1) * pageSize, page * pageSize)) {
  435. let p = personsTable.fetch(x.id)
  436. if (p != null && p.urlSegment != null) {
  437. let photo = photoUrlOf(p)
  438. tiles.push({ href = '/person/' + p.urlSegment posterUrl = photo != '' ? photo : '/profiles/none' title = p.name != null ? '' + p.name : '' year = '' })
  439. }
  440. }
  441. return { page = page pages = pages tiles = tiles }
  442. }

Branches

Latest commits

  • 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
  • 84e1b3e1tracker: reports 025 + 026mre
  • dc40d859tracker#31 (mission 026): duplicate titles merged — the 68 type+tmdbId pairs held by 157 records were the old tracker's (all migrated); merge.hl repair job (own clock, before the TMDB jobs) keeps one keeper per title (follows/watches > old short id > oldest), moves follows, watches, seasons, cast, credits, timelines, tombstones the rest (mergedInto, never deleted), slugs + short ids 301 to the keeper; stray seasons merged into their listed twin (Reacher S3 watches) or linked when watched; search import re-checks before its put; deploy.sh waits up to 90 s for 200; real copy 68 -> 0 dup ids, az5b2 follows/watches equal; gates 342/0, 32/0, 52/0mre