diff options
| author | Fuwn <[email protected]> | 2026-03-27 11:05:26 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-03-27 11:05:26 +0000 |
| commit | 57025734d0bcac7acab49cacb5cf5dd6af5be7d3 (patch) | |
| tree | 0db8eb6e563ad691e29f3f55b0cfa1d2a4c90d3f /apps/proxy/src/mangadex.js | |
| parent | fix(proxy): improve native manga chapter counts (diff) | |
| download | due.moe-57025734d0bcac7acab49cacb5cf5dd6af5be7d3.tar.xz due.moe-57025734d0bcac7acab49cacb5cf5dd6af5be7d3.zip | |
fix(manga): restore progress-based volume recommendations
Diffstat (limited to 'apps/proxy/src/mangadex.js')
| -rw-r--r-- | apps/proxy/src/mangadex.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/apps/proxy/src/mangadex.js b/apps/proxy/src/mangadex.js index d2a42154..dea33e70 100644 --- a/apps/proxy/src/mangadex.js +++ b/apps/proxy/src/mangadex.js @@ -223,9 +223,37 @@ const chooseLatestAggregateChapter = (volumes) => { return latest; }; +const buildVolumeChapterBoundaries = (volumes) => { + const boundaries = {}; + + for (const [volumeKey, volumeEntry] of Object.entries(volumes || {})) { + const chapters = volumeEntry?.chapters || {}; + + for (const chapterEntry of Object.values(chapters)) { + const volumeText = + chapterEntry?.volume || volumeEntry?.volume || volumeKey || null; + const volumeNumber = parseOptionalNumber(volumeText); + const chapterNumber = parseOptionalNumber(chapterEntry?.chapter || null); + + if (volumeNumber === null || chapterNumber === null) continue; + + const key = String(volumeNumber); + const current = boundaries[key]; + + if (current === undefined || chapterNumber > current) + boundaries[key] = chapterNumber; + } + } + + return Object.keys(boundaries).length ? boundaries : null; +}; + const buildIndexedRow = (manga, mangadexId, aggregateResponse) => { const now = new Date().toISOString(); const latest = chooseLatestAggregateChapter(aggregateResponse?.volumes); + const volumeChapterBoundaries = buildVolumeChapterBoundaries( + aggregateResponse?.volumes, + ); return { anilist_id: manga.anilistId, @@ -233,6 +261,7 @@ const buildIndexedRow = (manga, mangadexId, aggregateResponse) => { latest_en_chapter_text: latest?.chapterText || null, latest_en_chapter_number: latest?.chapterNumber || null, latest_en_volume_text: latest?.volumeText || null, + volume_chapter_boundaries: volumeChapterBoundaries, latest_en_chapter_id: latest?.chapterId || null, latest_chapter_updated_at: now, last_seen_at: now, |