From 13b76ba2e054209aa6f3610aba08ee0975d01475 Mon Sep 17 00:00:00 2001 From: Bruno Bernardino Date: Tue, 15 Oct 2024 17:31:10 +0100 Subject: [PATCH] Fix news cleanup cron (was deleting even in feeds without recent articles) --- crons/news.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crons/news.ts b/crons/news.ts index 3d2cfe0..2a25a3b 100644 --- a/crons/news.ts +++ b/crons/news.ts @@ -41,10 +41,10 @@ export async function cleanupOldArticles() { for (const feed of feeds) { const recentArticlesCount = (await db.query<{ count: number }>( sql`SELECT COUNT("id") AS "count" FROM "bewcloud_news_feed_articles" WHERE "feed_id" = $1 AND "article_date" >= $2`, - [feed.id, oneMonthAgo], + [feed.id, oneMonthAgo.toISOString().substring(0, 10)], ))[0].count; - // Don't delete old articles if the feed doesn't have recent articles (to skip feeds with less items in total) + // Don't delete old articles if the feed doesn't have many recent articles (low frequency feeds) if (recentArticlesCount <= 5) { feedIdsToSkip.add(feed.id); }