Skip to content

Commit f5cb84d

Browse files
committed
allow resuming active jobs that is not yet failed
1 parent 5c45bf9 commit f5cb84d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Models/Queue.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ export class Queue {
254254
const timeoutUpperBound = (queueLifespanRemaining - 500 > 0) ? queueLifespanRemaining - 499 : 0; // Only get jobs with timeout at least 500ms < queueLifespanRemaining.
255255

256256
const initialQuery = (queueLifespanRemaining)
257-
? 'active == FALSE AND failed == null AND timeout > 0 AND timeout < ' + timeoutUpperBound
258-
: 'active == FALSE AND failed == null';
257+
? '(active == FALSE AND failed == null AND timeout > 0 AND timeout < ' + timeoutUpperBound + ') OR (active == FALSE AND failed == null AND timeout > 0 AND timeout < ' + timeoutUpperBound + ')'
258+
: '(active == FALSE AND failed == null) OR (active == TRUE && failed == null)';
259259

260260
let jobs = this.realm.objects('Job')
261261
.filtered(initialQuery)
@@ -271,8 +271,8 @@ export class Queue {
271271
const concurrency = this.worker.getConcurrency(nextJob.name);
272272

273273
const allRelatedJobsQuery = (queueLifespanRemaining)
274-
? 'name == "'+ nextJob.name +'" AND active == FALSE AND failed == null AND timeout > 0 AND timeout < ' + timeoutUpperBound
275-
: 'name == "'+ nextJob.name +'" AND active == FALSE AND failed == null';
274+
? '(name == "'+ nextJob.name +'" AND active == FALSE AND failed == null AND timeout > 0 AND timeout < ' + timeoutUpperBound + ') OR (name == "'+ nextJob.name +'" AND active == FALSE AND failed == null AND timeout > 0 AND timeout < ' + timeoutUpperBound + ')'
275+
: '(name == "'+ nextJob.name +'" AND active == FALSE AND failed == null) OR (name == "'+ nextJob.name +'" AND active == TRUE AND failed == null)';
276276

277277
const allRelatedJobs = this.realm.objects('Job')
278278
.filtered(allRelatedJobsQuery)

0 commit comments

Comments
 (0)