fix(identity): 季表只计 TMDB / 人工来源或已确认的季,资源懒建的临时季不算(M2)

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 23:31:20 +08:00
1 parent fa18015354
commit 074dab04ca
1 file changed
+8 -1
@@ -38,7 +38,11 @@ const ENDED_STATUSES = new Set(["ended", "canceled", "cancelled"]);
/** 待处理证据里最多列多少条资源 */ /** 待处理证据里最多列多少条资源 */
const DECISION_LIST_LIMIT = 50; const DECISION_LIST_LIMIT = 50;
/** 作品季表:季号 ≥ 0 的季单元;最新季 = 季号 ≥ 1 的最大季单元 */ /**
* 作品季表:季号 ≥ 0 的季单元;最新季 = 季号 ≥ 1 的最大季单元。
* 只计元数据(tmdb)/ 人工(user)来源或已确认的季单元:资源 / 文件懒建的临时季(解析错的 S05 之类)不进季表,
* 否则它总集数为空会让该季资源一律按「元数据滞后」放行,还会抬高最新季。
*/
export async function loadSeasonTable(exec: Exec, entityId: string): Promise<SeasonTable> { export async function loadSeasonTable(exec: Exec, entityId: string): Promise<SeasonTable> {
const entity = await exec const entity = await exec
.selectFrom("media_entity") .selectFrom("media_entity")
@@ -52,6 +56,8 @@ export async function loadSeasonTable(exec: Exec, entityId: string): Promise<Sea
"season_number", "season_number",
"episode_number", "episode_number",
"episode_total", "episode_total",
"status",
"source",
sql<string | null>`to_char(air_date, 'YYYY-MM-DD')`.as("air"), sql<string | null>`to_char(air_date, 'YYYY-MM-DD')`.as("air"),
]) ])
.where("media_entity_id", "=", entityId) .where("media_entity_id", "=", entityId)
@@ -63,6 +69,7 @@ export async function loadSeasonTable(exec: Exec, entityId: string): Promise<Sea
const seasons = new Map<number, SeasonInfo>(); const seasons = new Map<number, SeasonInfo>();
for (const u of units) { for (const u of units) {
if (u.kind !== "season" || u.season_number === null || u.season_number < 0) continue; if (u.kind !== "season" || u.season_number === null || u.season_number < 0) continue;
if (u.status !== "confirmed" && u.source !== "tmdb" && u.source !== "user") continue;
const cur = seasons.get(u.season_number); const cur = seasons.get(u.season_number);
// 重复季单元(并发懒建遗留)取已知的较大总集数 // 重复季单元(并发懒建遗留)取已知的较大总集数
const total = u.episode_total ?? null; const total = u.episode_total ?? null;