voyager 3: release_texts, the searchable strings of a release (migration 6200)
Test and deploy / test (push) Failing after 52s
Test and deploy / edge (push) Successful in 1m52s
Test and deploy / deploy (push) Skipped

One table and one trigram index for every string search matches against:
the release name (kind 1, stored once more) and what anyone learns later
(the prober's file names inside an archive, NFO titles, par2 set names,
media titles), appended by insert, never an update of the releases row.
Kinds and the per-kind cap in lib/release/text_kind.ts (textsToStore).
The judge's dirty mark follows an insert or delete. Migration 6000 loses
its two trigram indexes on releases.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Fable 5.1 committed 2026-10-25 20:33:28 +01:00
1 parent 346493b6c3
commit bc4e17e86f
5 files changed
+161 -13

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
import { test } from '@japa/runner'
import {
TEXT_KINDS,
TEXTS_PER_KIND,
TEXT_MAX,
textKindCode,
textKindName,
textsToStore,
} from '#lib/release/text_kind'
test.group('release text kinds', () => {
test('names and codes map both ways; the codes are fixed', ({ assert }) => {
assert.deepEqual(TEXT_KINDS, { name: 1, file: 2, nfo: 3, par2: 4, media: 5 })
for (const [name, code] of Object.entries(TEXT_KINDS)) {
assert.equal(textKindCode(name), code)
assert.equal(textKindName(code), name)
assert.equal(textKindName(String(code)), name)
}
})
test('an unknown name throws, an unknown code reads as unknown', ({ assert }) => {
assert.throws(() => textKindCode('title'), /Unknown release text kind/)
assert.equal(textKindName(99), 'unknown')
assert.equal(textKindName(null), 'unknown')
})
test('textsToStore trims, cuts, drops empties and repeats, keeps the first TEXTS_PER_KIND', ({
assert,
}) => {
const long = 'x'.repeat(TEXT_MAX + 10)
assert.deepEqual(textsToStore([' a.mkv ', '', null, 'a.mkv', 'b.mkv', long]), [
'a.mkv',
'b.mkv',
'x'.repeat(TEXT_MAX),
])
const many = Array.from({ length: TEXTS_PER_KIND + 5 }, (_, i) => `file${i}.rar`)
const kept = textsToStore(many)
assert.lengthOf(kept, TEXTS_PER_KIND)
assert.equal(kept[0], 'file0.rar')
assert.equal(kept[TEXTS_PER_KIND - 1], `file${TEXTS_PER_KIND - 1}.rar`)
})
})