Skip to content

Commit

Permalink
fix: align attemptsMade to the behavior of BullMQ.
Browse files Browse the repository at this point in the history
closes #386
  • Loading branch information
felixmosh committed Mar 22, 2022
1 parent bd7a6c0 commit 7ea0bbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions packages/api/src/queueAdapters/bull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@ export class BullAdapter extends BaseAdapter {
}

public getJob(id: string): Promise<Job | undefined | null> {
return this.queue.getJob(id);
return this.queue.getJob(id).then((job) => {
if (typeof job?.attemptsMade === 'number') {
job.attemptsMade++;
}
return job;
});
}

public getJobs(jobStatuses: JobStatus[], start?: number, end?: number): Promise<Job[]> {
return this.queue.getJobs(jobStatuses, start, end);
return this.queue.getJobs(jobStatuses, start, end).then((jobs) =>
jobs.map((job) => {
job.attemptsMade++; // increase to align it with bullMQ behavior
return job;
})
);
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/JobCard/JobCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const JobCard = ({ job, status, actions, readOnlyMode, allowRetries }: Jo
<div className={s.title}>
<h4>
{job.name}
{job.attempts > 0 && <span>attempt #{job.attempts + 1}</span>}
{job.attempts > 1 && <span>attempt #{job.attempts}</span>}
{!!job.opts?.repeat?.count && (
<span>
repeat {job.opts?.repeat?.count}
Expand Down

0 comments on commit 7ea0bbc

Please sign in to comment.