fix(anilist): treat the anchor as season 1 in the air-order continuation check

pickByAirOrder skipped the named-season guard for an anchor whose titles name
no season, so a "Season 2" entry with a "Part 2" synonym was dropped as a
back half and season 2 could not be picked.
This commit is contained in:
sudacode committed 2026-11-22 15:22:33 -08:00
1 parent 11da02e4e9
commit 2b6e589ab3
2 files changed
+26 -1

No files matched your search

@@ -623,6 +623,25 @@ test('a sequel naming its own season is not a back half, even with a part synony
assert.equal(unnamed.result?.id, 2); assert.equal(unnamed.result?.id, 2);
}); });
test('air order keeps a sequel naming its own season despite a part synonym', () => {
const anchor: AnilistSeasonMedia = {
id: 1,
episodes: 12,
format: 'TV',
seasonYear: 2020,
title: { english: 'Air Order Show' },
};
const sequel: AnilistSeasonMedia = {
id: 2,
episodes: 12,
format: 'TV',
seasonYear: 2022,
title: { english: 'Air Order Show Season 2' },
synonyms: ['Air Order Show Part 2'],
};
assert.equal(pickByAirOrder(anchor, 2, [anchor, sequel])?.id, 2);
});
test('a season 1 episode past its length does not move to a longer later season', async () => { test('a season 1 episode past its length does not move to a longer later season', async () => {
const { result } = await resolveInChain( const { result } = await resolveInChain(
[ [
+7 -1
View File
@@ -620,7 +620,13 @@ export function pickByAirOrder(
// spells it "<season> Part 1" is kept. // spells it "<season> Part 1" is kept.
const seasons = franchise.filter((entry) => { const seasons = franchise.filter((entry) => {
if (entry.id === anchor.id) return true; if (entry.id === anchor.id) return true;
return !franchise.some((other) => other.id !== entry.id && isSeasonContinuation(other, entry)); // The anchor is season 1 here, which lets the continuation check reject an entry
// naming another season even when the anchor's own titles name none.
return !franchise.some(
(other) =>
other.id !== entry.id &&
isSeasonContinuation(other, entry, other.id === anchor.id ? 1 : null),
);
}); });
if (seasons.length < season) return null; if (seasons.length < season) return null;