tracker
All repositories: gitoria
6.3 KB
// tests/seed-bulk.hl — FIXTURE for mission 044 (jobs in slices): a few thousand rows spread over every primary-key slice, so the// sliced scans (lib/slices.hl) and the sliced merge prepare are compared with the old whole-table scans on more than the gate's// handful of titles. Written into TRACKER_STORAGE while the app is STOPPED; random ids (copy the store before comparing).// 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// or not), every 25th show twice (same type + tmdbId → a duplicate group, the 2nd one seasons-less), 1–2 listed seasons of 2 episodes,// every 40th title a stray season; a watch on every 7th episode; a follow on every 11th show; a person crediting every 13th show.// oldIds are 24-hex Mongo ids (the first 8 digits = seconds: the duplicate is younger) so the merge's keeper pick never ties.// Also three rows whose ids are NOT hex ('tmdb-…', 'Zed', '0') to prove the slices partition any key.import { MPackDB } from 'hl:mpackdb'import { env } from 'hl:proc'storageDir = env('TRACKER_STORAGE')if (storageDir == null || !storageDir.startsWith('/')) { hlError('set TRACKER_STORAGE, absolute') }n = env('TRACKER_SEED_BULK') != null ? toNumber(env('TRACKER_SEED_BULK')) : 3000showsTable = new MPackDB(file = storageDir + '/shows.db', primaryKey = '@id', indexes = ['!oldId'], compact = false)seasonsTable = new MPackDB(file = storageDir + '/seasons.db', primaryKey = '@id', indexes = ['!oldId'], compact = false)episodesTable = new MPackDB(file = storageDir + '/episodes.db', primaryKey = '@id', indexes = ['!oldId'], compact = false)followsTable = new MPackDB(file = storageDir + '/follows.db', primaryKey = '@id', indexes = ['!oldId'])watchesTable = new MPackDB(file = storageDir + '/watches.db', primaryKey = '@id', indexes = ['!oldId'])personsTable = new MPackDB(file = storageDir + '/persons.db', primaryKey = '@id', indexes = ['!oldId'], compact = false)// deterministic pseudo-random 16-hex ids (the same store can be seeded twice: old tree / new tree)ridState = { c = 0 }hex8 = (v) => { h = v.toString(16) return '00000000'.slice(0, 8 - h.length) + h }rid = () => {ridState.c = ridState.c + 1return hex8((ridState.c * 2654435761) % 4294967296) + hex8((ridState.c * 40503 + 977) % 4294967296)}putShow = (id, i, tmdb, listed, flavor) => {type = i % 3 == 0 ? 'movie' : 'series'adult = i % 5 == 0 ? true : (i % 5 == 1 ? false : null)showsTable.put({ id = id title = 'Bulk ' + i tmdbId = tmdb type = type adult = adult kind = (i % 4 == 0 && type == 'series') ? 'series' : nulltvmzId = i % 7 == 2 ? 7000 + i : null tvmazeStatus = i % 12 == 0 ? 'Ended' : null tvmazeType = i % 12 == 0 ? 'Scripted' : nullimage = i % 2 == 0 ? '/posters/x' + i : null runtime = (type == 'movie' && i % 2 == 0) ? 90 : null genres = []seasons = listed urlSegment = 'bulk-' + i + flavor mergedInto = null oldId = hex8((flavor == '' ? 1000000 : 2000000) + i) + '0000000000000000'creditsAt = i % 9 == 0 ? 1 : null detailsAt = i % 8 == 0 ? 1 : null tmdbSync = i % 7 == 0 ? 1 : null artAt = i % 10 == 0 ? 1 : null })return true}let i = 0while (i < n) {let listed = []let s = 0while (s < (i % 3)) {sid = rid()listed.push(sid)seasonsTable.put({ id = sid, show = null, seasonNumber = s + 1, episodes = [], oldId = 's' + i + '-' + s })s = s + 1}id = rid()putShow(id, i, 100000 + i, listed, '')// the season rows name their showfor (sid of listed) {let row = seasonsTable.fetch(sid)row.show = idlet eps = []let e = 0while (e < 2) {eid = rid()eps.push(eid)episodesTable.put({ id = eid, season = sid, show = id, episodeNumber = e + 1, oldId = 'e' + i + '-' + e })// a double episode of the same number in every 50th title's first seasonif (i % 50 == 10 && e == 0) { episodesTable.put({ id = rid(), season = sid, show = id, episodeNumber = 1, oldId = 'd' + i }) }if ((i + e) % 7 == 0) { watchesTable.put({ id = rid(), user = 'bulku', target = eid, targetType = 'episode', oldId = 'w' + eid }) }e = e + 1}row.episodes = epsseasonsTable.update(sid, row)}if (i % 25 == 0) {// 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,// a watch on its first episode, a follow on every other onedid = rid()dsid = rid()deps = [rid(), rid()]seasonsTable.put({ id = dsid, show = did, seasonNumber = (i % 50 == 0) ? 1 : 2, episodes = deps, oldId = 'ds' + i })episodesTable.put({ id = deps[0], season = dsid, show = did, episodeNumber = 1, oldId = 'de' + i + '-0' })episodesTable.put({ id = deps[1], season = dsid, show = did, episodeNumber = 2, oldId = 'de' + i + '-1' })watchesTable.put({ id = rid(), user = 'bulku' + (i % 3), target = deps[0], targetType = 'episode', oldId = 'dw' + i })putShow(did, i, 100000 + i, [dsid], '-dup')if (i % 50 == 25) { followsTable.put({ id = rid(), user = 'bulku', show = did, oldId = 'df' + i }) }}if (i % 40 == 1 && i % 3 != 0) {stid = rid()seasonsTable.put({ id = stid, show = id, seasonNumber = 1, episodes = [], oldId = 'stray' + i })if (i % 80 == 1) { watchesTable.put({ id = rid(), user = 'bulku', target = stid, targetType = 'season', oldId = 'sw' + i }) }}if (i % 11 == 0) { followsTable.put({ id = rid(), user = 'bulku', show = id, oldId = 'f' + i }) }if (i % 13 == 0) { personsTable.put({ id = rid(), name = 'Bulk Person ' + i, tmdbId = 500000 + i, shows = [{ show = id, role = 'cast' }], oldId = 'p' + i }) }i = i + 1}showsTable.put({ id = 'tmdb-zz1', title = 'NonHex 1', tmdbId = 1, type = 'movie', adult = null, seasons = [], urlSegment = 'nonhex-1', oldId = 'nh1' })showsTable.put({ id = 'Zed', title = 'NonHex 2', tmdbId = 2, type = 'movie', adult = null, seasons = [], urlSegment = 'nonhex-2', oldId = 'nh2' })showsTable.put({ id = '0', title = 'NonHex 3', tmdbId = 3, type = 'series', adult = null, seasons = [], urlSegment = 'nonhex-3', oldId = 'nh3' })showsTable.persist()seasonsTable.persist()episodesTable.persist()followsTable.persist()watchesTable.persist()personsTable.persist()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
- d2e6d26bMerge branch 'records-park55' into mainTracker
- f567f025|||PR records: park #55, no Claude workers ruleTracker
- c21aff6bMerge branch 'records-hm55c' into mainTracker
- 9ba258d3|||PR records: HM55b resultTracker
- 64f2d300Merge branch 'records-hm55b2' into mainTracker
- ae3b80dc|||PR records: HM55b briefTracker
- 7ef3cb3bMerge branch 'records-st55' into mainTracker
- fec2e080|||PR records: STATUS HM55Tracker
- 8e174918Merge branch 'records-hm55b' into mainTracker
- b1ecee57|||PR records: HM55 stateTracker
- 28eab08cMerge branch 'records-hm55' into mainTracker
- d3edaa05|||PR records: HM55 start, PROCEDURES.mdTracker
- 3059f86cMerge branch 'records-design-rule' into mainTracker
- 421a4809|||PR records: his-design rule (Apollo 2026-11-13)Tracker
- d1390692Merge branch 'records-dp75b' into mainTracker
- a4d1a7d2|||PR records: later steps checked, branch auditTracker
- e070e16fMerge branch 'records-dp75' into mainTracker
- 642b4fa8|||PR records: DP75 day62 live, AP62 briefTracker
- bfc4ea4dMerge branch 'ap62' into mainTracker
- 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker