gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd25bd14ad25bd14amission 044: sliced merge prepare + sliced collections prepare; jobs-dump old/new check + bulk fixturemred25bd14a/tests/seed-bulk.hl

6.3 KB

  1. // tests/seed-bulk.hl — FIXTURE for mission 044 (jobs in slices): a few thousand rows spread over every primary-key slice, so the
  2. // sliced scans (lib/slices.hl) and the sliced merge prepare are compared with the old whole-table scans on more than the gate's
  3. // handful of titles. Written into TRACKER_STORAGE while the app is STOPPED; random ids (copy the store before comparing).
  4. // Per i in 0..N-1: a show (type series / movie, adult true / false / unknown, kind set / unset, a TVmaze id, a poster or not, merged
  5. // or not), every 25th show twice (same type + tmdbId → a duplicate group, the 2nd one seasons-less), 1–2 listed seasons of 2 episodes,
  6. // every 40th title a stray season; a watch on every 7th episode; a follow on every 11th show; a person crediting every 13th show.
  7. // oldIds are 24-hex Mongo ids (the first 8 digits = seconds: the duplicate is younger) so the merge's keeper pick never ties.
  8. // Also three rows whose ids are NOT hex ('tmdb-…', 'Zed', '0') to prove the slices partition any key.
  9. import { MPackDB } from 'hl:mpackdb'
  10. import { env } from 'hl:proc'
  11. storageDir = env('TRACKER_STORAGE')
  12. if (storageDir == null || !storageDir.startsWith('/')) { hlError('set TRACKER_STORAGE, absolute') }
  13. n = env('TRACKER_SEED_BULK') != null ? toNumber(env('TRACKER_SEED_BULK')) : 3000
  14. showsTable = new MPackDB(file = storageDir + '/shows.db', primaryKey = '@id', indexes = ['!oldId'], compact = false)
  15. seasonsTable = new MPackDB(file = storageDir + '/seasons.db', primaryKey = '@id', indexes = ['!oldId'], compact = false)
  16. episodesTable = new MPackDB(file = storageDir + '/episodes.db', primaryKey = '@id', indexes = ['!oldId'], compact = false)
  17. followsTable = new MPackDB(file = storageDir + '/follows.db', primaryKey = '@id', indexes = ['!oldId'])
  18. watchesTable = new MPackDB(file = storageDir + '/watches.db', primaryKey = '@id', indexes = ['!oldId'])
  19. personsTable = new MPackDB(file = storageDir + '/persons.db', primaryKey = '@id', indexes = ['!oldId'], compact = false)
  20. // deterministic pseudo-random 16-hex ids (the same store can be seeded twice: old tree / new tree)
  21. ridState = { c = 0 }
  22. hex8 = (v) => { h = v.toString(16) return '00000000'.slice(0, 8 - h.length) + h }
  23. rid = () => {
  24. ridState.c = ridState.c + 1
  25. return hex8((ridState.c * 2654435761) % 4294967296) + hex8((ridState.c * 40503 + 977) % 4294967296)
  26. }
  27. putShow = (id, i, tmdb, listed, flavor) => {
  28. type = i % 3 == 0 ? 'movie' : 'series'
  29. adult = i % 5 == 0 ? true : (i % 5 == 1 ? false : null)
  30. showsTable.put({ id = id title = 'Bulk ' + i tmdbId = tmdb type = type adult = adult kind = (i % 4 == 0 && type == 'series') ? 'series' : null
  31. tvmzId = i % 7 == 2 ? 7000 + i : null tvmazeStatus = i % 12 == 0 ? 'Ended' : null tvmazeType = i % 12 == 0 ? 'Scripted' : null
  32. image = i % 2 == 0 ? '/posters/x' + i : null runtime = (type == 'movie' && i % 2 == 0) ? 90 : null genres = []
  33. seasons = listed urlSegment = 'bulk-' + i + flavor mergedInto = null oldId = hex8((flavor == '' ? 1000000 : 2000000) + i) + '0000000000000000'
  34. creditsAt = i % 9 == 0 ? 1 : null detailsAt = i % 8 == 0 ? 1 : null tmdbSync = i % 7 == 0 ? 1 : null artAt = i % 10 == 0 ? 1 : null })
  35. return true
  36. }
  37. let i = 0
  38. while (i < n) {
  39. let listed = []
  40. let s = 0
  41. while (s < (i % 3)) {
  42. sid = rid()
  43. listed.push(sid)
  44. seasonsTable.put({ id = sid, show = null, seasonNumber = s + 1, episodes = [], oldId = 's' + i + '-' + s })
  45. s = s + 1
  46. }
  47. id = rid()
  48. putShow(id, i, 100000 + i, listed, '')
  49. // the season rows name their show
  50. for (sid of listed) {
  51. let row = seasonsTable.fetch(sid)
  52. row.show = id
  53. let eps = []
  54. let e = 0
  55. while (e < 2) {
  56. eid = rid()
  57. eps.push(eid)
  58. episodesTable.put({ id = eid, season = sid, show = id, episodeNumber = e + 1, oldId = 'e' + i + '-' + e })
  59. // a double episode of the same number in every 50th title's first season
  60. if (i % 50 == 10 && e == 0) { episodesTable.put({ id = rid(), season = sid, show = id, episodeNumber = 1, oldId = 'd' + i }) }
  61. if ((i + e) % 7 == 0) { watchesTable.put({ id = rid(), user = 'bulku', target = eid, targetType = 'episode', oldId = 'w' + eid }) }
  62. e = e + 1
  63. }
  64. row.episodes = eps
  65. seasonsTable.update(sid, row)
  66. }
  67. if (i % 25 == 0) {
  68. // the duplicate: a season of number 1 or 2 (a twin of the original's → merged, or one the keeper lacks → moved) with 2 episodes,
  69. // a watch on its first episode, a follow on every other one
  70. did = rid()
  71. dsid = rid()
  72. deps = [rid(), rid()]
  73. seasonsTable.put({ id = dsid, show = did, seasonNumber = (i % 50 == 0) ? 1 : 2, episodes = deps, oldId = 'ds' + i })
  74. episodesTable.put({ id = deps[0], season = dsid, show = did, episodeNumber = 1, oldId = 'de' + i + '-0' })
  75. episodesTable.put({ id = deps[1], season = dsid, show = did, episodeNumber = 2, oldId = 'de' + i + '-1' })
  76. watchesTable.put({ id = rid(), user = 'bulku' + (i % 3), target = deps[0], targetType = 'episode', oldId = 'dw' + i })
  77. putShow(did, i, 100000 + i, [dsid], '-dup')
  78. if (i % 50 == 25) { followsTable.put({ id = rid(), user = 'bulku', show = did, oldId = 'df' + i }) }
  79. }
  80. if (i % 40 == 1 && i % 3 != 0) {
  81. stid = rid()
  82. seasonsTable.put({ id = stid, show = id, seasonNumber = 1, episodes = [], oldId = 'stray' + i })
  83. if (i % 80 == 1) { watchesTable.put({ id = rid(), user = 'bulku', target = stid, targetType = 'season', oldId = 'sw' + i }) }
  84. }
  85. if (i % 11 == 0) { followsTable.put({ id = rid(), user = 'bulku', show = id, oldId = 'f' + i }) }
  86. if (i % 13 == 0) { personsTable.put({ id = rid(), name = 'Bulk Person ' + i, tmdbId = 500000 + i, shows = [{ show = id, role = 'cast' }], oldId = 'p' + i }) }
  87. i = i + 1
  88. }
  89. showsTable.put({ id = 'tmdb-zz1', title = 'NonHex 1', tmdbId = 1, type = 'movie', adult = null, seasons = [], urlSegment = 'nonhex-1', oldId = 'nh1' })
  90. showsTable.put({ id = 'Zed', title = 'NonHex 2', tmdbId = 2, type = 'movie', adult = null, seasons = [], urlSegment = 'nonhex-2', oldId = 'nh2' })
  91. showsTable.put({ id = '0', title = 'NonHex 3', tmdbId = 3, type = 'series', adult = null, seasons = [], urlSegment = 'nonhex-3', oldId = 'nh3' })
  92. showsTable.persist()
  93. seasonsTable.persist()
  94. episodesTable.persist()
  95. followsTable.persist()
  96. watchesTable.persist()
  97. personsTable.persist()
  98. console.log('seed-bulk: ' + showsTable.count() + ' shows, ' + seasonsTable.count() + ' seasons, ' + episodesTable.count() + ' episodes, ' + watchesTable.count() + ' watches, ' + followsTable.count() + ' follows, ' + personsTable.count() + ' persons')

Branches

Latest commits

  • d25bd14amission 044: sliced merge prepare + sliced collections prepare; jobs-dump old/new check + bulk fixturemre
  • 633ee210mission 044: sliced table scans (slices.hl, pk-range slices) for the adult/kind/status/art/credits/details-repair queuesmre
  • 6648ba44mission 042: real-browser E2E on ce6f2e0a re-vendor 69/0 at 390 + 1280mre
  • 3ed3a0efmission 042: gates old/new equal (browser #41 route-table regex accepts unescaped hl:web output), real-data TTFB, E2E blocked by lisbeth lockmre
  • d5b61e90LOG 042mre
  • 4acdbaccmission 042: memory comparison old vs ce6f2e0a (stopped: warm VmHWM higher), reportmre
  • d0f620d6mission 042: re-vendor Hybriel ce6f2e0a (plugins incl. mpackdb; bin runtime built from the same archive, git-ignored), compact=false keptmre
  • 5bd14e12mission 040: theme 76f99f6 gates + E2E green; 44 px fixes (skeleton row, type-word, genre-link/pill); README, reportmre
  • 77cfa45cmission 040: partial report (theme/modal/pagination re-copied, tilelist onPage, 44 px taps; gates new + E2E pending)mre
  • 4b14822fe2e-theme: menu marker by colourmre
  • 09780f4emission 040 WIP: theme, modal, pagination, tokens re-copied from layouts 76f99f6; tilelist uses onPage; tap sizes 44 px for tracker's own small buttons; tests/e2e-theme.mjsmre
  • fb80bb8chotfix: open the 5 show stores without compaction (compact = false) — compact-on-open left another handle on stale offsets, every read gave a bare Number (hybriel mpackdb refresh after a shrink); live down 2026-10-20 05:11mre
  • e00d3bf7paths: projects moved into /media/STORAGE/projects/WorldAPI/mre
  • a8c7f234tracker#36 (mission 039): tools/tmdb-check.hl survives a dropped connection (on Error, asked again, failed lines) and resumes with --from N; tests/tmdbcheck.mjs 6/6 against a fake TMDBmre
  • 9c230516mission brief w39mre
  • 3609121dmission 038 docs + report (quota stop): README/kinds.md for #43 #42 #36, STATUS, LOG; HEAD browser gate 374/8 in the in-app daily run block (hour-boundary suspected, rerun pending), other gates green; #36 real run needs TMDB_READ_TOKENmre
  • a5d06e79tracker#36 (mission 038): tools/tmdb-check.hl + lib/tmdbcheck.hl — every live migrated title's migrated title + year against its TMDB entry (one GET /movie|tv/<id>?append_to_response=alternative_titles, 260 ms apart, passing failures asked once more): ok / ambiguous (one of title, year disagrees) / clear (both, or 404); read-only; token only from TMDB_READ_TOKEN; --stored = a title-only preview from the TMDB names already stored (no request). Tested against a fake TMDB (.scratch/w38/t36): 7 titles, 3 ok, 2 ambiguous, 2 clear, data unchangedmre
  • 982554f3tracker#42 (mission 038): series pages — an unknown slug no longer scans every title (lib/shows.hl showBySlug: the slug map only; new titles are noted by refreshTitleCaches, which both title puts already reach): 10.7–15.7 s → 0.013 s on the real copy (the one-request-at-a-time server was blocked meanwhile); cast/crew rows take name + slug from a person-link cache (personLinkOf) instead of whole person records (SNL: 303 cast with 4,761 credits, ~49k allocations per render) — allocations per series page −5…−40 %; HTML of 20 pages identical to beforemre
  • 4586b6e3docker-compose: init: true (hybriel#156)mre
  • 085c2e5ftracker#43 (mission 038): TVmaze's type makes Variety / Talk Show / Game Show / Reality / News / Panel Show / Award Show / Sports titles Shows (TMDB calls Saturday Night Live UK Scripted) — the #43 part of parked w37-wip a79c8c1 only (no re-vendor, no cache volume): tvmazeType stored by the sync and the TVmaze status backfill (asks every series with a TVmaze id once), kindOfTitle/kindWithTvmaze, tools/tvmaze-types.hl, gate fixture Variety Gate Series; start waits 150 smre