chg: [cleanup] added function to check for prio worker's existance in Event.php

pull/3530/head
iglocska 2018-08-03 10:27:44 +02:00
parent e8b2a03f23
commit ba52868982
1 changed files with 14 additions and 18 deletions

View File

@ -3356,21 +3356,25 @@ class Event extends AppModel
}
}
private function __getPrioWorkerIfPossible() {
$this->ResqueStatus = new ResqueStatus\ResqueStatus(Resque::redis());
$workers = $this->ResqueStatus->getWorkers();
$workerType = 'default';
foreach ($workers as $worker) {
if ($worker['queue'] === 'prio') {
$workerType = 'prio';
}
}
return $workerType;
}
public function publishRouter($id, $passAlong = null, $user)
{
if (Configure::read('MISP.background_jobs')) {
$job = ClassRegistry::init('Job');
$job->create();
$this->ResqueStatus = new ResqueStatus\ResqueStatus(Resque::redis());
$workers = $this->ResqueStatus->getWorkers();
$workerType = 'default';
foreach ($workers as $worker) {
if ($worker['queue'] === 'prio') {
$workerType = 'prio';
}
}
$data = array(
'worker' => $workerType,
'worker' => $this->__getPrioWorkerIfPossible(),
'job_type' => 'publish_event',
'job_input' => 'Event ID: ' . $id,
'status' => 0,
@ -4720,16 +4724,8 @@ class Event extends AppModel
if (Configure::read('MISP.background_jobs')) {
$job = ClassRegistry::init('Job');
$job->create();
$this->ResqueStatus = new ResqueStatus\ResqueStatus(Resque::redis());
$workers = $this->ResqueStatus->getWorkers();
$workerType = 'default';
foreach ($workers as $worker) {
if ($worker['queue'] === 'prio') {
$workerType = 'prio';
}
}
$data = array(
'worker' => $workerType,
'worker' => $this->__getPrioWorkerIfPossible(),
'job_type' => 'enrichment',
'job_input' => 'Event ID: ' . $options['event_id'] . ' modules: ' . json_encode($options['modules']),
'status' => 0,