fetch old items for existing subscribed feeds

This commit is contained in:
Hongbo Wu
2024-06-13 14:15:19 +08:00
parent 28bd2c4e25
commit c82efb31d3

View File

@ -88,12 +88,20 @@ export const isOldItem = (
item: RssFeedItem,
mostRecentItemTimestamp: number
) => {
// existing items and items that were published before 24h
const publishedAt = item.isoDate ? new Date(item.isoDate) : new Date()
return (
publishedAt <= new Date(mostRecentItemTimestamp) ||
publishedAt < new Date(Date.now() - 24 * 60 * 60 * 1000)
)
// always fetch items without isoDate
if (!item.isoDate) {
return false
}
const publishedAt = new Date(item.isoDate)
// don't fetch older than 24 hrs items for new feeds
if (!mostRecentItemTimestamp) {
return publishedAt < new Date(Date.now() - 24 * 60 * 60 * 1000)
}
// don't fetch existing items for old feeds
return publishedAt <= new Date(mostRecentItemTimestamp)
}
const feedFetchFailedRedisKey = (feedUrl: string) =>