From 4c072c665191619472472cc23c9e2e322611afce Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 29 Mar 2026 05:07:06 +0000 Subject: fix(proxy): improve native chapter source routing --- apps/proxy/src/index.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'apps/proxy/src/index.js') diff --git a/apps/proxy/src/index.js b/apps/proxy/src/index.js index 26121f10..592899c0 100644 --- a/apps/proxy/src/index.js +++ b/apps/proxy/src/index.js @@ -267,10 +267,16 @@ const handleMangaChapterCounts = async (request, env, ctx) => { .filter((row) => isRecentFailure(row, bootstrapRetryMinutes(env))) .map((row) => row.anilist_id), ); - const rowsNeedingBackfill = manga.filter((entry) => { + const rowsMissingFromIndex = manga.filter((entry) => { const row = existingRowsById.get(entry.anilistId); if (!row) return !recentFailures.has(entry.anilistId); + return false; + }); + const rowsNeedingVolumeBackfill = manga.filter((entry) => { + const row = existingRowsById.get(entry.anilistId); + + if (!row) return false; return ( entry.progress > 0 && @@ -278,12 +284,19 @@ const handleMangaChapterCounts = async (request, env, ctx) => { !recentFailures.has(entry.anilistId) ); }); - const pendingRows = rowsNeedingBackfill.filter((entry) => + const rowsNeedingBackfill = [ + ...rowsMissingFromIndex, + ...rowsNeedingVolumeBackfill, + ]; + const pendingRows = rowsMissingFromIndex.filter((entry) => bootstrapInFlight.has(entry.anilistId), ); const queueableRows = rowsNeedingBackfill.filter( (entry) => !bootstrapInFlight.has(entry.anilistId), ); + const queueablePendingRows = rowsMissingFromIndex.filter( + (entry) => !bootstrapInFlight.has(entry.anilistId), + ); if (queueableRows.length) ctx.waitUntil( @@ -311,7 +324,7 @@ const handleMangaChapterCounts = async (request, env, ctx) => { ); const pending = [ ...new Set( - [...pendingRows, ...queueableRows].map((entry) => entry.anilistId), + [...pendingRows, ...queueablePendingRows].map((entry) => entry.anilistId), ), ]; -- cgit v1.2.3