From d43ef653655a0d1ad597ecfe88625aca06f6ac00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20Sundf=C3=B8r?= Date: Mon, 8 Apr 2024 10:37:56 +0200 Subject: [PATCH] Do not write to DB if there aren't new episodes We currently do a lot of unessecary DB writes. This PR should fix that. This is important because it can get expensive rather quickly. --- lib/caching.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/caching.ts b/lib/caching.ts index 67e4ac1..72eec24 100644 --- a/lib/caching.ts +++ b/lib/caching.ts @@ -20,6 +20,10 @@ async function updateFetch(existingSeries: Series) { return !existingSeries.episodes.find((serieEpisode) => serieEpisode.id === episode.id); }); + if (newEpisodes.length === 0) { + return existingSeries; + } + const updated = { ...existingSeries, lastFetch: new Date(),