Enqueue new feeds at front

This commit is contained in:
Jackson Harper
2024-01-18 14:34:07 +08:00
parent ee142d3d7c
commit fb28d7b3d1
2 changed files with 8 additions and 2 deletions

View File

@ -90,9 +90,12 @@ export const queueRSSRefreshAllFeedsJob = async () => {
return queue.add('refresh-all-feeds', {})
}
type QueuePriority = 'low' | 'high'
export const queueRSSRefreshFeedJob = async (
jobid: string,
payload: any
payload: any,
options = { priority: 'high' as QueuePriority }
): Promise<Job | undefined> => {
const queue = createBackendQueue()
if (!queue) {
@ -102,5 +105,6 @@ export const queueRSSRefreshFeedJob = async (
jobId: jobid,
removeOnComplete: true,
removeOnFail: true,
lifo: options.priority == 'high',
})
}

View File

@ -660,7 +660,9 @@ export const enqueueRssFeedFetch = async (
)}_${stringToHash(JSON.stringify(subscriptionGroup.userIds.sort()))}`
if (redisDataSource.workerRedisClient) {
let job = await queueRSSRefreshFeedJob(jobid, payload)
let job = await queueRSSRefreshFeedJob(jobid, payload, {
priority: 'high',
})
if (!job || !job.id) {
throw 'unable to queue rss-refresh-feed-job, job did not enqueue'
}