gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit3251488a3251488atracker#7: /my/shows (followed shows, newest follow first, poster, title, last watched SxxEyy); gate can take screenshots (TRACKER_GATE_SHOTS)mre3251488a/tests/seed-show.hl

5.7 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' oldId = 'g1' })
  39. personsTable.put({ id = personId name = 'Test Actor' urlSegment = 'Test-Actor' oldId = 'p1' })
  40. seasonsTable.put({ id = season1Id seasonNumber = 1 title = null release = null summary = null show = showId episodes = [ep1Id, ep2Id] oldId = 's1' })
  41. seasonsTable.put({ id = season2Id seasonNumber = 2 title = null release = null summary = null show = showId episodes = [ep3Id] oldId = 's2' })
  42. episodesTable.put({ id = ep1Id episodeNumber = 1 seasonNumber = 1 title = 'Pilot' summary = null release = '2020-01-01' show = showId season = season1Id oldId = 'ep1' })
  43. episodesTable.put({ id = ep2Id episodeNumber = 2 seasonNumber = 1 title = 'Second' summary = null release = '2020-06-15' show = showId season = season1Id oldId = 'ep2' })
  44. episodesTable.put({ id = ep3Id episodeNumber = 1 seasonNumber = 2 title = 'Season Two Opener' summary = null release = '2099-01-01' show = showId season = season2Id oldId = 'ep3' })
  45. showsTable.put({
  46. id = showId title = 'Gate Test Show' summary = 'a fixture show for the gate' tmdbSummary = null tmdbId = null
  47. language = 'en' type = 'series' release = null year = 2024 image = 'jpg' urlSegment = 'gate-test-show'
  48. episodesCount = 3 homepage = null imdbId = null seasonsCount = 2 status = 'Ended' tagline = null
  49. tvdbId = null tvmzId = null genres = [genreId] cast = [{ person = personId character = 'Someone' actor = 'Test Actor' }]
  50. seasons = [season1Id, season2Id] oldId = 'sh1'
  51. })
  52. show2Id = 'sh00000000000sh2'
  53. showsTable.put({
  54. id = show2Id title = 'Unwatched Gate Show' summary = null tmdbSummary = null tmdbId = null
  55. language = 'en' type = 'series' release = null year = 2025 image = null urlSegment = 'unwatched-gate-show'
  56. episodesCount = 0 homepage = null imdbId = null seasonsCount = 0 status = 'Ended' tagline = null
  57. tvdbId = null tvmzId = null genres = [] cast = [] seasons = [] oldId = 'sh2'
  58. })
  59. identity = env('TRACKER_SEED_IDENTITY')
  60. userId = 'gateu0000000000u1'
  61. if (identity != null && identity != '') {
  62. usersTable.put({ id = userId identity = identity created = now() })
  63. // tracker.worldapi.org#7 (/my/shows, newest follow first): the fixture show was followed a day ago, a
  64. // second show (no seasons, no poster name, never watched) just now — stored AFTER it, so the page's
  65. // order has to come from `at`, not from the table's own order
  66. followsTable.put({ id = 'gatef000000000f1' show = showId user = userId at = now() - 86400000 oldId = 'gate-follow-1' })
  67. followsTable.put({ id = 'gatef000000000f2' show = show2Id user = userId at = now() oldId = 'gate-follow-2' })
  68. }
  69. genresTable.persist()
  70. personsTable.persist()
  71. showsTable.persist()
  72. seasonsTable.persist()
  73. episodesTable.persist()
  74. watchesTable.persist()
  75. usersTable.persist()
  76. followsTable.persist()
  77. 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

  • 3251488atracker#7: /my/shows (followed shows, newest follow first, poster, title, last watched SxxEyy); gate can take screenshots (TRACKER_GATE_SHOTS)mre
  • 44b7d9f9tracker#6: /schedule — upcoming episodes of followed shows, soonest firstmre
  • 91c9fc8ctracker#5: /unwatched — unwatched released episodes of followed shows, newest firstmre
  • a97c0295tracker#4: show page /shows/:slug (header, seasons, episodes, watch checks) + tools/relink-episode-seasons.hlmre
  • 05f407c5tracker: no border on any button except inverted ones (Log out, ident status and identities too); header brand weight 100mre
  • 17375427tracker#2: tools/migrate.hl + tools/verify.hl — old MongoDB data into mpackdb with new idsmre
  • 31aac936tracker#3: no border on the header and on filled buttons; inverted buttons keep theirsmre
  • 2ad9d29ctracker#1: login exactly like calendar (identity selector in the header, empty homepage)mre
  • 3691e176tracker#1: empty tracker with the ident login (state of 2026-09-27)mre