fix(acquisition): 集数待确认的资源在订阅侧写候选记录

评估跳过 episode_unresolved 时,给仍在追踪的收录版本各写一条 skipped 候选评估
(原因 episode_unresolved),作品「为什么选 / 不选」与订阅记录能看到"集数待确认"。
确认后重发评估按 (收录版本, 资源) 覆盖;换算到别的季不再进入原收录版本时,
先清掉旧的待确认记录,不留陈旧原因。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-10-03 20:46:40 +08:00
1 parent 00045a24cb
commit 4d24edd94c
2 files changed
+82 -1

No files matched your search

@@ -156,4 +156,47 @@ describe.skipIf(!hasPg)("订阅评估跳过集数待确认的资源", () => {
expect(ev.plans).toHaveLength(0);
expect(ev.skipped).toEqual([{ sourceReleaseId: id, reason: "episode_unresolved" }]);
});
it("集数待确认在订阅侧可见:写候选记录 episode_unresolved;确认后正常评估并覆盖", async () => {
const slot = await h.db
.selectFrom("acquisition_slot")
.select("id")
.where("media_entity_id", "=", entityId)
.executeTakeFirstOrThrow();
const candidate = async (releaseId: string) =>
(
await h.db
.selectFrom("artifact")
.select("content")
.where("title", "=", "candidate_evaluation")
.where("subject_id", "=", slot.id)
.execute()
)
.map(
(r) => r.content as { sourceReleaseId: string; decision: string; reasons: string[]; planId: string | null },
)
.find((c) => c.sourceReleaseId === releaseId);
const id = await seed(LILITH_40);
await evaluateAcquisition(h.d, { sourceReleaseId: id });
expect(await candidate(id)).toMatchObject({ decision: "skipped", reasons: ["episode_unresolved"] });
// 人工确认为 S02E12(与 `- 24` 的换算结果相同),重发评估:正常建计划,记录被覆盖
const fixed = resolved("[Lilith-Raws] Kusuriya no Hitorigoto - 24 [Baha][WEB-DL][1080p][AVC AAC][CHT][MP4]");
const cols = toParsedColumns(fixed.parsed);
await h.db
.updateTable("source_release")
.set({
parsed: JSON.stringify(cols.parsed),
parser_version: cols.parserVersion,
episode_resolution: JSON.stringify(fixed.resolution),
})
.where("id", "=", id)
.execute();
const ev = await evaluateAcquisition(h.d, { sourceReleaseId: id });
expect(ev.plans, JSON.stringify(ev)).toHaveLength(1);
const c = await candidate(id);
expect(c?.decision).toBe("accept");
expect(c?.planId).toBe(ev.plans[0]);
expect(c?.reasons).not.toContain("episode_unresolved");
});
});