fix(identity): include episode and recognition words in resolve idempotency
This commit is contained in:
1 parent
864856c9bb
commit
27386ba9df
3 files changed
+39
-4
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { type ParsedRelease, parseRelease } from "@umt/domain";
|
||||
import { expect, it } from "vitest";
|
||||
import { evidenceVersion } from "../../src/modules/sources-identity/service/resolve.ts";
|
||||
|
||||
it("身份候选不变时,季集和规则匹配输入变化也必须重算;相同事实仍幂等", () => {
|
||||
const original = parseRelease("[Lilith-Raws] Example S01E40 [1080p]");
|
||||
const before = evidenceVersion(original, []);
|
||||
const changes: Partial<ParsedRelease>[] = [
|
||||
{ season: 2 },
|
||||
{ seasonEnd: 2 },
|
||||
{ seasonInferred: true },
|
||||
{ episodes: { start: 12, end: 12 } },
|
||||
{ airDate: "20250314" },
|
||||
{ releaseGroup: { name: "ANi", source: "bracket" } },
|
||||
{ words: { applied: ["Example >> EP-28"], original: original.raw } },
|
||||
];
|
||||
for (const change of changes) expect(evidenceVersion({ ...original, ...change }, [])).not.toBe(before);
|
||||
expect(evidenceVersion(structuredClone(original), [])).toBe(before);
|
||||
});
|
||||
@@ -307,7 +307,7 @@ describe.skipIf(!pg)("识别词接口", () => {
|
||||
const g = (await call("/identify-words/global")).body.data;
|
||||
const saved = await call("/identify-words/global", {
|
||||
method: "PUT",
|
||||
body: { text: `${g.text}Kusuriya no Hitorigoto - 4 <> \\[Baha >> EP-28\n`, expectedVersion: g.version },
|
||||
body: { text: `${g.text}Kusuriya no Hitorigoto - (?=4\\d) <> \\[Baha >> EP-28\n`, expectedVersion: g.version },
|
||||
});
|
||||
const version = saved.body.data.block.version as number;
|
||||
const before = h.engine.enqueued.length;
|
||||
@@ -321,15 +321,19 @@ describe.skipIf(!pg)("识别词接口", () => {
|
||||
expect(p.scanned).toBeGreaterThanOrEqual(4);
|
||||
|
||||
// 重新识别后集数按全局识别词偏移(40 → 12,对上第 1 季),命中的行记在解析结果上
|
||||
await resolveRelease(h.rt, { sourceReleaseId: lilith40, force: true, trigger: "review" });
|
||||
const resolved = await resolveRelease(h.rt, { sourceReleaseId: lilith40, force: true, trigger: "review" });
|
||||
expect(resolved.outcome).toBe("auto");
|
||||
const row = await h.db
|
||||
.selectFrom("source_release")
|
||||
.select(["parsed"])
|
||||
.where("id", "=", lilith40)
|
||||
.executeTakeFirstOrThrow();
|
||||
expect((row.parsed as { words?: { applied: string[] } }).words?.applied).toEqual([
|
||||
"Kusuriya no Hitorigoto - 4 <> \\[Baha >> EP-28",
|
||||
"Kusuriya no Hitorigoto - (?=4\\d) <> \\[Baha >> EP-28",
|
||||
]);
|
||||
expect(await er(lilith40)).toMatchObject({ source: { season: 1, episodes: { start: 12, end: 12 } } });
|
||||
const unchanged = await resolveRelease(h.rt, { sourceReleaseId: lilith40, force: true, trigger: "review" });
|
||||
expect(unchanged).toMatchObject({ outcome: "skipped", reason: "unchanged" });
|
||||
});
|
||||
|
||||
it("全局示例:没给标题时从近期资源里找命中的", async () => {
|
||||
|
||||
Reference in new issue
Block a user