gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit1eb6f1a11eb6f1a1Missions AP56, BS1mre1eb6f1a1/lib/export.hl

1.8 KB

  1. // lib/export.hl — READING THE OLD TRACKER'S MONGO EXPORT (/media/STORAGE/projects/old-tracker/mongo-export/*.jsonl, EJSON, one
  2. // document per line): the lines of a file, a Mongo id, the chunk workaround for big files. Used by the one-off tools
  3. // tools/migrate.hl (tracker.worldapi.org#2) and tools/old-short-ids.hl (mission 060). Mission 028: was copied into both.
  4. import { run } from 'hl:proc'
  5. import { readFile, mkDir, exists } from 'hl:fs'
  6. static nl = "
  7. "
  8. static linesOf = (&path) => {
  9. raw = readFile(path)
  10. if (raw == null) { return [] }
  11. out = []
  12. for (l of raw.split(nl)) { if (l != '') { out.push(l) } }
  13. return out
  14. }
  15. static oidOf = (&v) => {
  16. if (v == null) { return null }
  17. if (hlTypeName(v) == 'String') { return v }
  18. return v['$oid']
  19. }
  20. // hl:fs readFile SILENTLY TRUNCATES at 10 MiB (fs.zig hl_fs_read_file, max_size = 1024*1024*10,
  21. // no error, no flag — reported as a Hybriel gap, tracker.worldapi.org#2): Show.jsonl (12.4 MB),
  22. // Season.jsonl (10.9 MB) and Episode.jsonl (140 MB) are all over it. Worked around WITHOUT
  23. // touching the vendored plugin: `split` (coreutils, via hl:proc run — no shell, no JS) cuts the
  24. // export into <10 MB chunks in a scratch dir first; each chunk is read whole (well under the cap).
  25. static padNum4 = (&n) => {
  26. let s = '' + n
  27. while (s.length < 4) { s = '0' + s }
  28. return s
  29. }
  30. static bigLinesOf = (&path, &chunkDir, &perChunk) => {
  31. mkDir(chunkDir, 448)
  32. r = run(['split', '-l', '' + perChunk, '-d', '-a', '4', '--additional-suffix=.jsonl', path, chunkDir + '/c_'])
  33. if (r == null || r.exit != 0) { hlError('split failed for ' + path) }
  34. out = []
  35. let idx = 0
  36. while (true) {
  37. fp = chunkDir + '/c_' + padNum4(&idx) + '.jsonl'
  38. if (!exists(fp)) { break }
  39. for (l of linesOf(&fp)) { out.push(l) }
  40. idx = idx + 1
  41. }
  42. if (idx == 0) { hlError('no chunks produced for ' + path) }
  43. return out
  44. }

Branches

Latest commits

  • 1eb6f1a1Missions AP56, BS1mre
  • 4871f8adLog: AP52 live on day52, browser gate greenmre
  • d9bf2988Merge ap52: day52, tracker#58 server argument, #51 modal close rule, #56 keyed season rowsmre
  • c4a60ef2Log: RT52 retest passed, AP52 startedmre
  • 83760a55Browser gate: search results belong to the address form of the typed text (tracker#52 navigate replace)mre
  • 6e951d91AP52: show-page rows are keyed records; closing a season is one upsert and removes (tracker#56, hybriel#331)mre
  • 3bb4ccddAP52: modal close button refers to its nested rule with Style.buttonModalX (tracker#51, hybriel#333)mre
  • ba16933fAP52: login callback and title route are static handlers taking the server as third argument (tracker#58, hybriel#332)mre
  • 85153900AP52: re-vendor Hybriel set day52 (source 77cfca31, bin 0a8ed496)mre
  • 7c051eddLog: hybriel#338 answermre
  • d049b8b8Log: HM50 live, #52 donemre
  • 6d05fa37Log: HM50 Part A mergedmre
  • 1c7dab74HM50: the shell reads the framework's online state, netProbe removed (tracker#55)mre
  • e8b91697HM50: search address follows the text via navigate(path, replace = true) (tracker#52)mre
  • 6fe1896cHM50: re-vendor Hybriel set day50 (source 0ae38232, bin d3ef9d16)mre
  • 2f391aa9Log: HM50 startedmre
  • 4b59c03dHM50 mission: doc pathmre
  • ed526d67HM50 missionmre
  • 2f986ca3Log: RT50 passmre
  • 1c4715a4RT50 mission: day50 repro retestmre