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
- f57f64f0mission 046: report, LOGmre
- efe1b485mission 046: re-vendor Hybriel master 60b2817b (integration 8, #203): plugins mpackdb + web (bin/ git-ignored: hybriel, libhlrt.a, hlc.o, hlrt/ from native/zig-out)mre
- 53099ffbmission 046: person page reads a slim per-title credit row cache (no whole-record fetch per credit); gate tests/person-lookup.mjsmre
- 9b3828aemission 046a: report, LOGmre
- 4b37356emission 046: franchise seed supersedeCollections reads the curated timelines once (10 s one-tick block at the end of boot)mre
- ac6268e3mission 046a: re-vendor Hybriel 528bc89f (integration 6): plugins mpackdb/time/web (bin/ git-ignored)mre
- 322b3293mission 046: photoQueue guard for non-row fetch results (damaged persons index)mre
- e5b99aecmission 046: photoQueue in slices (people.hl photoQueueStart/Step, jobs.hl photoTick), tests/photoqueue.hlmre
- 31dcf2admission 045: report, LOGmre
- 9c3971d0tests/persons-skip-count.hlmre
- 4d72e365mission 045mre
- b9cae4c9slices: skip and count non-row values from range(); merge persons pass falls back to iterate; guard testmre
- 3db7dc31merge w44-jobs-slices into w43-trkmemmre
- 593dab6fmission 043: report, LOGmre
- 1a5a4818boot scans back to iterate (slices measured slower: titles 114 s, episodes 141 s, persons failed); lambda per rowmre
- 03d29893boot scans read primary-key slices (lib/slices.hl from mission 044): iterate is eager too; people view log line back; allShows/allEpisodes stay for toolsmre
- 23375c58mission 044: report, LOG, STATUSmre
- c6fd928emission 044: 4096 slices for tables over 200 K rows, 15 ms budget, TRACKER_SLICE_DEPTH for testsmre
- fb057680mission 044: jobs.hl imports mergeLeft (gate found it), mission file, slices benchmre
- 0d6293ebmission 043: mission filemre