Skip to content

Commit

Permalink
feat: remove exiting job on force refresh (#1321)
Browse files Browse the repository at this point in the history
remove exiting job on force refresh
  • Loading branch information
justraman authored Sep 30, 2024
1 parent 7082151 commit 7b131d7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/jobs/process-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export const metadataQueue = new Queue<JobData>('metadataQueue', {
})

export const processMetadata = async (resourceId: string, type: JobData['type'], force = false, allTokens = false) => {
if (force) {
// on force, remove existing job and add a new one
const existingJob = await metadataQueue.getJob(`${type}-${resourceId}`)
if (existingJob) {
await existingJob.remove()
}
}

metadataQueue.add({ resourceId, type, force, allTokens }, { jobId: `${type}-${resourceId}` }).catch(() => {
// eslint-disable-next-line no-console
console.log('Closing connection as Redis is not available')
Expand Down

0 comments on commit 7b131d7

Please sign in to comment.