mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Dont fail whole job if we cant update a subscription group
This commit is contained in:
parent
65347a1996
commit
5a7056b7ec
1 changed files with 37 additions and 18 deletions
|
|
@ -31,30 +31,49 @@ export const refreshAllFeeds = async (db: DataSource): Promise<boolean> => {
|
|||
)) as RssSubscriptionGroup[]
|
||||
|
||||
for (const group of subscriptionGroups) {
|
||||
const jobid = `refresh-feed_${stringToHash(group.url)}_${stringToHash(
|
||||
JSON.stringify(group.userIds.sort())
|
||||
)}`
|
||||
const payload = {
|
||||
subscriptionIds: group.subscriptionIds,
|
||||
feedUrl: group.url,
|
||||
lastFetchedTimestamps: group.fetchedDates.map(
|
||||
(timestamp) => timestamp?.getTime() || 0
|
||||
), // unix timestamp in milliseconds
|
||||
lastFetchedChecksums: group.checksums,
|
||||
scheduledTimestamps: group.scheduledDates.map((timestamp) =>
|
||||
timestamp.getTime()
|
||||
), // unix timestamp in milliseconds
|
||||
userIds: group.userIds,
|
||||
fetchContents: group.fetchContents,
|
||||
folders: group.folders,
|
||||
try {
|
||||
await updateSubscriptionGroup(group)
|
||||
} catch (err) {
|
||||
// we don't want to fail the whole job if one subscription group fails
|
||||
console.error('error updating subscription group')
|
||||
}
|
||||
|
||||
await queueRSSRefreshFeedJob(jobid, payload)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const updateSubscriptionGroup = async (group: RssSubscriptionGroup) => {
|
||||
const feedURL = group.url
|
||||
const userList = JSON.stringify(group.userIds.sort())
|
||||
if (!feedURL) {
|
||||
console.error('no url for feed group', group)
|
||||
return
|
||||
}
|
||||
if (!userList) {
|
||||
console.error('no userlist for feed group', group)
|
||||
return
|
||||
}
|
||||
const jobid = `refresh-feed_${stringToHash(feedURL)}_${stringToHash(
|
||||
userList
|
||||
)}`
|
||||
const payload = {
|
||||
subscriptionIds: group.subscriptionIds,
|
||||
feedUrl: group.url,
|
||||
lastFetchedTimestamps: group.fetchedDates.map(
|
||||
(timestamp) => timestamp?.getTime() || 0
|
||||
), // unix timestamp in milliseconds
|
||||
lastFetchedChecksums: group.checksums,
|
||||
scheduledTimestamps: group.scheduledDates.map((timestamp) =>
|
||||
timestamp.getTime()
|
||||
), // unix timestamp in milliseconds
|
||||
userIds: group.userIds,
|
||||
fetchContents: group.fetchContents,
|
||||
folders: group.folders,
|
||||
}
|
||||
|
||||
await queueRSSRefreshFeedJob(jobid, payload)
|
||||
}
|
||||
|
||||
const createBackendQueue = (): Queue | undefined => {
|
||||
if (!redisDataSource.workerRedisClient) {
|
||||
throw new Error('Can not create queues, redis is not initialized')
|
||||
|
|
|
|||
Loading…
Reference in a new issue