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
- fdf10b1alog: RV28d deployed on day38bmre
- 320005e9log: RV28d merged, deploy runningmre
- a8fef27dRV28d: reportmre
- 2bae8373RV28d: re-vendor Hybriel set day38b (source 1e554d75, bin 5ff2a46d)mre
- 16b3354aMerge branch 'main' into rv28cmre
- 6f4f27d8log: RV28d started (day38b)mre
- e6cf03ffmission RV28d: rv28c onto day38bmre
- 3ccaee19status: live sweep freeze, waiting for Apollomre
- 49f76ecblog: watch toggle slowness = session sweep freeze (tracker#50)mre
- 3daf6eddlog: day37 live, still waiting for day39mre
- 796ba672records: #277 slips to day39mre
- a9eb9827records: mpackdb integrity clean, all 12 tablesmre
- 6cf40dbdrecords: mpackdb integrity check, shows uncheckedmre
- 1880f42arecords: day38 deploy may swap normallymre
- 9d806e35records: mpackdb freeze until day38mre
- a660239drecords: day37 lacks #277, wait for day38mre
- b0abfdeaLOG: Anton hybriel#277 fix ready for day37mre
- 7b5b2918Tracker: hybriel#277 fix comes in day37mre
- 7ddbeec8Tracker: RV28c blocked on day35 regressionmre
- 529096e8RV28c: reportmre