Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jadiscke committed Jul 29, 2022
1 parent b5f1086 commit 3295481
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bull-script.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ async function retryJobs(jobsArray) {
}))
}

async function cleanJobs(jobsArray) {
await Promise.all(jobsArray.map( async (jobId) => {
const result = await fetch(`${URL}/api/queues/UseCaseJob/${jobId}/clean`, {method: 'put', headers: headers})
console.log(result.statusText)
}))
}

async function wait(waitingTime) {
await new Promise((resolve, reject) => {
if ( waitingTime < 0 ){
Expand All @@ -41,11 +48,11 @@ for (let i = START_PAGE; i >= END_PAGE; i--) {
}

const response = await fetch(
`${URL}/api/queues?activeQueue=UseCaseJob&status=failed&page=${i}`,
`${URL}/api/queues?activeQueue=UseCaseJob&status=completed&page=${i}`,
{ method: "get", headers: headers }
)

const jobsIds = (await response.json()).queues[0].jobs.map(element => element.id)
retryJobs(jobsIds).catch((error) => { console.log(error)})
cleanJobs(jobsIds).catch((error) => { console.log(error)})

}

0 comments on commit 3295481

Please sign in to comment.