diff --git a/Sources/QueuesMongoDriver/Queues.swift b/Sources/QueuesMongoDriver/Queues.swift index a5a38c6..e1bf7c0 100644 --- a/Sources/QueuesMongoDriver/Queues.swift +++ b/Sources/QueuesMongoDriver/Queues.swift @@ -97,8 +97,15 @@ class MongoQueue: Queue { } } + // Mark jobs that can't be finished as ready. func push(_ id: JobIdentifier) -> EventLoopFuture { - context.eventLoop.future() + mongodb["vapor_queue"] + .findAndModify(where: ["jobid": id.string, + "queue": "\(context.queueName.string)", + "status": "processing"], + update: ["$set": ["status": MongoJobStatus.ready.rawValue]]) + .execute() + .transform(to: ()) } }