From a293266ccd72bc053189fd406d6d1bd64a6f4f9e Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Sat, 9 Nov 2024 18:17:16 +0100 Subject: [PATCH] (feed) Wipe the feeds db and start over from system URLs periodically. --- .../java/nu/marginalia/rss/svc/FeedFetcherService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/functions/live-capture/java/nu/marginalia/rss/svc/FeedFetcherService.java b/code/functions/live-capture/java/nu/marginalia/rss/svc/FeedFetcherService.java index 2b398af4..f9ca3079 100644 --- a/code/functions/live-capture/java/nu/marginalia/rss/svc/FeedFetcherService.java +++ b/code/functions/live-capture/java/nu/marginalia/rss/svc/FeedFetcherService.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.net.http.HttpClient; import java.sql.SQLException; import java.time.Duration; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -89,7 +90,12 @@ public class FeedFetcherService { // RSS exports instead Collection definitions = feedDb.getAllFeeds(); - if (definitions == null) { + + // If we didn't get any definitions, or approximately every other month, read them from the system + // to get the latest feeds. As the feeds known by the system have a lot of dead links, we don't + // want to do this too often. + final LocalDate today = LocalDate.now(); + if (definitions == null || (today.getDayOfMonth() == 1 && (today.getMonthValue() % 2) == 0)) { definitions = readDefinitionsFromSystem(); }