mirror of
https://github.com/idanoo/laravel-resque.git
synced 2025-07-05 04:32:13 +00:00
fix detect duplicate job
This commit is contained in:
parent
e230e66b48
commit
0663765b47
4 changed files with 14 additions and 18 deletions
|
@ -62,10 +62,8 @@ class ResqueManager
|
|||
$queue = new Queue($job->queue());
|
||||
|
||||
foreach ($queue->jobs() as $queuedJob) {
|
||||
if ($job->payload['class'] === get_class($queuedJob) && count(array_intersect($queuedJob->getArguments(),
|
||||
$job->arguments())) === $job->arguments()
|
||||
) {
|
||||
return ($trackStatus) ? new \Resque_Job_Status($job->payload['id']) : null;
|
||||
if (true === $this->isDuplicateJob($job, $queuedJob)) {
|
||||
return ($trackStatus) ? new \Resque_Job_Status($queuedJob->payload['id']) : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,18 +98,14 @@ class ResqueManager
|
|||
}
|
||||
|
||||
/**
|
||||
* @param array $queues
|
||||
* @param int $interval
|
||||
* @param int $logLevel
|
||||
* @param \Hlgrrnhrdt\Resque\Job $job
|
||||
* @param $queuedJob
|
||||
*
|
||||
* @return \Resque_Worker
|
||||
* @return bool
|
||||
*/
|
||||
public function startWorker(array $queues, $interval = 5, $logLevel = Resque_Worker::LOG_NONE)
|
||||
private function isDuplicateJob(Job $job, \Resque_Job $queuedJob)
|
||||
{
|
||||
$worker = new Resque_Worker($queues);
|
||||
$worker->logLevel = $logLevel;
|
||||
$worker->work($interval);
|
||||
|
||||
return $worker;
|
||||
return $queuedJob->payload['class'] === get_class($queuedJob)
|
||||
&& count(array_intersect($queuedJob->getArguments(), $job->arguments())) === count($job->arguments());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue