gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit1704ec451704ec45tracker#17 (mission 057): season caret down/up, skeleton rows while a season loads, sessionless showSeasonEpisodes face (no page re-mount), client-only close; gate 214, tests/realdata-057.mjs, README + STATUSmre1704ec45/tests/seed-show.hl

11.2 KB

  1. // tests/seed-show.hl — GATE FIXTURE for tracker.worldapi.org#4/#5: one small show with two seasons and
  2. // three episodes, written directly into a fresh storage/mpackdb/ (given as TRACKER_STORAGE) before the
  3. // gate server starts. Not the real migrated data (tests/browser.mjs does not run the real migration —
  4. // too slow for a gate) — just enough to drive the show page's and /unwatched's own checks.
  5. //
  6. // tracker.worldapi.org#5: episode 1 and 2 carry a PAST release date (so /unwatched shows them),
  7. // episode 3 a FAR FUTURE one (so /unwatched proves it excludes not-yet-released episodes). If
  8. // TRACKER_SEED_IDENTITY is set (the gate learns it from a throwaway ident exchange, since the real
  9. // login flow's `ensureUser` matches an EXISTING users.db row by `identity`, reusing its id rather than
  10. // minting a new one), a fixed user + a follow of this show for that user are seeded too — that is the
  11. // only way to give /unwatched a known, pre-followed show before the browser ever signs in.
  12. //
  13. // IDS ARE SELF-ASSIGNED (fixed literals, one put() per record — never update()), the same rule
  14. // tools/migrate.hl follows for its real two-way references (Show.seasons/Season.show, Episode.show/
  15. // season): hl:mpackdb's update() can lose rows across a reopen in a fresh process (hybriel#113) — and
  16. // the gate DOES reopen this same storage dir in a fresh process right after this script exits.
  17. import { MPackDB } from 'hl:mpackdb'
  18. import { env } from 'hl:proc'
  19. import { now } from 'hl:time'
  20. storageDir = env('TRACKER_STORAGE')
  21. if (storageDir == null || !storageDir.startsWith('/')) { hlError('set TRACKER_STORAGE, absolute') }
  22. genresTable = new MPackDB(file = storageDir + '/genres.db', primaryKey = '@id', indexes = ['!oldId'])
  23. personsTable = new MPackDB(file = storageDir + '/persons.db', primaryKey = '@id', indexes = ['!oldId'])
  24. showsTable = new MPackDB(file = storageDir + '/shows.db', primaryKey = '@id', indexes = ['!oldId'])
  25. seasonsTable = new MPackDB(file = storageDir + '/seasons.db', primaryKey = '@id', indexes = ['!oldId'])
  26. episodesTable = new MPackDB(file = storageDir + '/episodes.db', primaryKey = '@id', indexes = ['!oldId'])
  27. watchesTable = new MPackDB(file = storageDir + '/watches.db', primaryKey = '@id', indexes = ['!oldId'])
  28. usersTable = new MPackDB(file = storageDir + '/users.db', primaryKey = '@id', indexes = ['!identity'])
  29. followsTable = new MPackDB(file = storageDir + '/follows.db', primaryKey = '@id', indexes = ['!oldId'])
  30. genreId = 'g0000000000000g1'
  31. personId = 'p0000000000000p1'
  32. showId = 'sh00000000000sh1'
  33. season1Id = 'se000000000se0s1'
  34. season2Id = 'se000000000se0s2'
  35. ep1Id = 'ep0000000000ep0e1'
  36. ep2Id = 'ep0000000000ep0e2'
  37. ep3Id = 'ep0000000000ep0e3'
  38. genresTable.put({ id = genreId name = 'Drama' urlSegment = 'Drama' tmdbId = 18 oldId = 'g1' })
  39. // tracker.worldapi.org#16: Test Actor (the cast link of show 1) has a tmdbId → its page fetches the filmography from the fake TMDB
  40. personsTable.put({ id = personId name = 'Test Actor' urlSegment = 'Test-Actor' tmdbId = 3002 oldId = 'p1' })
  41. seasonsTable.put({ id = season1Id seasonNumber = 1 title = null release = null summary = null show = showId episodes = [ep1Id, ep2Id] oldId = 's1' })
  42. seasonsTable.put({ id = season2Id seasonNumber = 2 title = null release = null summary = null show = showId episodes = [ep3Id] oldId = 's2' })
  43. episodesTable.put({ id = ep1Id episodeNumber = 1 seasonNumber = 1 title = 'Pilot' summary = null release = '2020-01-01' show = showId season = season1Id oldId = 'ep1' })
  44. episodesTable.put({ id = ep2Id episodeNumber = 2 seasonNumber = 1 title = 'Second' summary = null release = '2020-06-15' show = showId season = season1Id oldId = 'ep2' })
  45. episodesTable.put({ id = ep3Id episodeNumber = 1 seasonNumber = 2 title = 'Season Two Opener' summary = null release = '2099-01-01' show = showId season = season2Id oldId = 'ep3' })
  46. showsTable.put({
  47. adult = false id = showId title = 'Gate Test Show' summary = 'a fixture show for the gate' tmdbSummary = null tmdbId = 1001
  48. language = 'en' type = 'series' release = null year = 2024 image = 'png' urlSegment = 'gate-test-show'
  49. episodesCount = 3 homepage = null imdbId = 'tt0000001' seasonsCount = 2 status = 'Ended' tagline = null
  50. tvdbId = null tvmzId = null genres = [genreId] cast = [{ person = personId character = 'Someone' actor = 'Test Actor' }]
  51. seasons = [season1Id, season2Id] oldId = 'sh1'
  52. })
  53. show2Id = 'sh00000000000sh2'
  54. showsTable.put({
  55. adult = false id = show2Id title = 'Unwatched Gate Show' summary = null tmdbSummary = null tmdbId = 1002
  56. language = 'en' type = 'series' release = '2025-03-01' year = null image = null urlSegment = 'unwatched-gate-show'
  57. episodesCount = 0 homepage = null imdbId = null seasonsCount = 0 status = 'Ended' tagline = null
  58. tvdbId = 4002 tvmzId = null genres = [] cast = [] seasons = [] oldId = 'sh2'
  59. })
  60. // tracker.worldapi.org#12 (link icons, external ids): show 1 has an imdbId only, show 2 a tvdbId only — the sync must fill
  61. // the missing ones (TMDB external_ids, TVmaze lookup) and never overwrite these. A MOVIE (tmdbId 1003, no imdbId):
  62. // TMDB + IMDb icons only, synced via /movie/, never /tv/ — followed by ANOTHER user (below), so alice's lists stay as they are
  63. show3Id = 'sh00000000000sh3'
  64. showsTable.put({
  65. adult = false id = show3Id title = 'Gate Test Movie' summary = 'a fixture movie' tmdbSummary = null tmdbId = 1003
  66. language = 'en' type = 'movie' release = '1996-11-18' year = 1996 image = null urlSegment = 'gate-test-movie'
  67. episodesCount = null homepage = null imdbId = null seasonsCount = null status = 'Released' tagline = null
  68. tvdbId = null tvmzId = null genres = [] cast = [] seasons = [] oldId = 'sh3'
  69. })
  70. // tracker.worldapi.org#13 (the homepage rows, /movies, /shows): 32 more movies, never followed — 'Pager Movie 01'…'30'
  71. // (released 2001-01-01 … 2001-01-30), 'Pager Future Movie' (2099-06-01: first on /movies, never in the homepage's "latest
  72. // released") and 'Pager Undated Movie' (no release: last) → 33 movies with the one above = 2 pages of 24. And a series
  73. // whose newest released episode (2021-01-01) is newer than show 1's (2020-06-15) but older than the S3E1 (2021-05-05) the
  74. // TMDB sync brings show 1 — so /shows reorders after the sync.
  75. // (Named 'Pager …', not 'Gate …', since the #13/#14 merge: the search checks (#14) expect exactly the 'gate' titles.)
  76. let mi = 1
  77. while (mi <= 30) {
  78. let nn = mi < 10 ? '0' + mi : '' + mi
  79. showsTable.put({
  80. adult = false id = 'mv00000000000m' + nn title = 'Pager Movie ' + nn summary = null tmdbSummary = null tmdbId = null
  81. language = 'en' type = 'movie' release = '2001-01-' + nn year = 2001 image = null urlSegment = 'pager-movie-' + nn
  82. episodesCount = null homepage = null imdbId = null seasonsCount = null status = null tagline = null
  83. tvdbId = null tvmzId = null genres = [] cast = [] seasons = [] oldId = 'mv' + nn
  84. })
  85. mi = mi + 1
  86. }
  87. showsTable.put({
  88. adult = false id = 'mv00000000000mfu' title = 'Pager Future Movie' summary = null tmdbSummary = null tmdbId = null
  89. language = 'en' type = 'movie' release = '2099-06-01' year = 2099 image = null urlSegment = 'pager-future-movie'
  90. episodesCount = null homepage = null imdbId = null seasonsCount = null status = null tagline = null
  91. tvdbId = null tvmzId = null genres = [] cast = [] seasons = [] oldId = 'mvfu'
  92. })
  93. showsTable.put({
  94. adult = false id = 'mv00000000000mun' title = 'Pager Undated Movie' summary = null tmdbSummary = null tmdbId = null
  95. language = 'en' type = 'movie' release = null year = null image = null urlSegment = 'pager-undated-movie'
  96. episodesCount = null homepage = null imdbId = null seasonsCount = null status = null tagline = null
  97. tvdbId = null tvmzId = null genres = [] cast = [] seasons = [] oldId = 'mvun'
  98. })
  99. show4Id = 'sh00000000000sh4'
  100. season4Id = 'se000000000se0s4'
  101. ep4Id = 'ep0000000000ep0e4'
  102. seasonsTable.put({ id = season4Id seasonNumber = 1 title = null release = null summary = null show = show4Id episodes = [ep4Id] oldId = 's4' })
  103. episodesTable.put({ id = ep4Id episodeNumber = 1 seasonNumber = 1 title = 'Older Pilot' summary = null release = '2021-01-01' show = show4Id season = season4Id oldId = 'ep4' })
  104. showsTable.put({
  105. adult = false id = show4Id title = 'Pager Older Series' summary = null tmdbSummary = null tmdbId = null
  106. language = 'en' type = 'series' release = '2019-01-01' year = 2019 image = null urlSegment = 'pager-older-series'
  107. episodesCount = 1 homepage = null imdbId = null seasonsCount = 1 status = 'Ended' tagline = null
  108. tvdbId = null tvmzId = null genres = [] cast = [] seasons = [season4Id] oldId = 'sh4'
  109. })
  110. // mission 054: every fixture title above is KNOWN non-adult (`adult = false`) — unknown or adult titles are hidden from the
  111. // public lists and the search; the adult block of the gate adds those itself (tests/seed-adult.hl)
  112. // tracker.worldapi.org#16 (person pages): a COMPLETE person (filmographyAt set: shown at once, TMDB never asked) with two credits
  113. // and the facts; a second INCOMPLETE one whose TMDB credits are titles the first fill (Test Actor) adds → linked, nothing added
  114. personsTable.put({ id = 'p0000000000000p2' name = 'Complete Person' urlSegment = 'Complete-Person' tmdbId = 3001 gender = 1
  115. birthDate = '1950-02-03' birthPlace = 'Gate City' deathDate = '2020-01-01' biography = 'A fixture person who is complete.' image = null
  116. shows = [{ show = showId character = 'Old Role' }, { show = show3Id character = 'Movie Role' }] filmographyAt = now() oldId = 'p2' })
  117. personsTable.put({ id = 'p0000000000000p3' name = 'Second Actor' urlSegment = 'Second-Actor' tmdbId = 3003 shows = [] oldId = 'p3' })
  118. // tracker.worldapi.org#9: both shows carry a tmdbId (1001, 1002) — the gate's fake TMDB (tests/faketmdb.mjs)
  119. // answers for exactly these two; the fixture episodes have no tmdbId, so the sync must match them by S/E number
  120. // tracker.worldapi.org#8: show 1 has a poster FILE (the gate writes posters/sh1.png) and a `year`; show 2 has
  121. // neither — its year comes from `release` (shows.hl showYear), its poster is the placeholder URL /posters/none
  122. identity = env('TRACKER_SEED_IDENTITY')
  123. userId = 'gateu0000000000u1'
  124. if (identity != null && identity != '') {
  125. usersTable.put({ id = userId identity = identity created = now() })
  126. // tracker.worldapi.org#7 (/my/shows, newest follow first): the fixture show was followed a day ago, a
  127. // second show (no seasons, no poster name, never watched) just now — stored AFTER it, so the page's
  128. // order has to come from `at`, not from the table's own order
  129. followsTable.put({ id = 'gatef000000000f1' show = showId user = userId at = now() - 86400000 oldId = 'gate-follow-1' })
  130. followsTable.put({ id = 'gatef000000000f2' show = show2Id user = userId at = now() oldId = 'gate-follow-2' })
  131. followsTable.put({ id = 'gatef000000000f3' show = show3Id user = 'gateu0000000000u2' at = now() oldId = 'gate-follow-3' })
  132. }
  133. genresTable.persist()
  134. personsTable.persist()
  135. showsTable.persist()
  136. seasonsTable.persist()
  137. episodesTable.persist()
  138. watchesTable.persist()
  139. usersTable.persist()
  140. followsTable.persist()
  141. console.log('seed: show ' + showId + ' (gate-test-show), seasons ' + season1Id + ',' + season2Id + ', episodes ' + ep1Id + ',' + ep2Id + ',' + ep3Id + (identity != null && identity != '' ? ', user ' + userId + ' follows it (and ' + show2Id + ')' : ', no follow (no identity given)'))

Branches

Latest commits

  • 1704ec45tracker#17 (mission 057): season caret down/up, skeleton rows while a season loads, sessionless showSeasonEpisodes face (no page re-mount), client-only close; gate 214, tests/realdata-057.mjs, README + STATUSmre
  • f2fe3e36mission 056: README + STATUS (merge, fixes, Hybriel 8590df63, real-data check), tests/realdata-056.mjs, tools/check-public-slugs.hlmre
  • f40c250emission 056: re-vendor hybriel master 8590df63 (#121, #122); an adult title's page is Not found for non-followers; gate: leave the page before stopping the servermre
  • 2b7fdd6cmission 056: signed-out header one row on phones ("Log in", nowrap), backfill skips adult titles' posters, gate checksmre
  • 2c53d5efMerge branch 't16-person' (tracker#16 person pages) into main; filmography shows only public titles (054 adult flag), gate race fix (backfill start line)mre
  • c171227emission 054: hide adult/unknown titles from the public lists and the search; in-app adult-flag backfill (TMDB details + poster per title, resumes), gate + real-data proofmre
  • 139fafd8tracker#16: short bio (4 lines, click = all), real-data check script, README + STATUSmre
  • 93be9476tracker#16: person pages /person/<slug> with the filmography fetched from TMDB on the first visit (step by step), gatemre
  • 47a3cae6STATUS: mission 053 merge commit idsmre
  • dcc5eecaMerge branch 't14-search'mre
  • 03edc783Merge branch 't15-tvmaze'mre
  • 71b46345tracker#15: numbering check by date or title, placeholder titles in other languages, docs + real-data proofmre
  • 6bb2daf1tracker#13: homepage (tiles, intro, latest movies/shows), /shows, /movies/page/N, /my/movies; lists cached in memorymre
  • b8bd1157tracker#14: README + STATUS (search, real-data numbers, gate, merge notes)mre
  • 65c694a8tracker#14: search — header magnifier, /search/<text> (in-memory word-prefix index over titles + people), Fetch from web (TMDB search/multi, ours left out), Add = import via syncShow; gate +25 checks, real-data scriptmre
  • 34f2c15btracker#15: TVmaze merge in the sync (gaps only: new episodes/seasons, empty titles/air dates; numbering check), fake TVmaze episodes + gatemre
  • cbdc4ea7tracker#12: link icons TMDB/IMDb/TVDB/TVmaze; sync fills missing ids (TVmaze lookup); movies fetched via /movie/mre
  • b105bcd8tracker#11: Hybriel master ff51cf46 (checks no longer vanish), mobile-first styles, carets, follow button, sign-in modal, inverted check, orange castmre
  • 31b758aatracker#10: installable app (manifest, service worker, offline shell), own icon + faviconmre
  • 2fa9d997tracker#9: TMDB sync (followed shows: seasons, episodes, posters), tools/sync-tmdb.hl + daily run 04:00 UTC, fake TMDB in gatemre