diff --git a/application/core/JQW_Controller.php b/application/core/JQW_Controller.php index 72a2a972b..2d471f03b 100644 --- a/application/core/JQW_Controller.php +++ b/application/core/JQW_Controller.php @@ -47,6 +47,19 @@ abstract class JQW_Controller extends JOB_Controller return $jobs; } + /** + * To get all the jobs specified by the given parameters + */ + protected function getJobsByTypeStatus($type, $status) + { + $jobs = $this->jobsqueuelib->getJobsByTypeStatus($type, $status); + + // If an error occurred then log it in database + if (isError($jobs)) $this->logError(getError($jobs), array($type, $status)); + + return $jobs; + } + /** * To get all the jobs specified by the given parameters */ diff --git a/application/libraries/JobsQueueLib.php b/application/libraries/JobsQueueLib.php index 0eb7c9b72..aaa318b97 100644 --- a/application/libraries/JobsQueueLib.php +++ b/application/libraries/JobsQueueLib.php @@ -56,6 +56,18 @@ class JobsQueueLib return $this->_ci->JobsQueueModel->loadWhere(array('status' => self::STATUS_NEW, 'type' => $type)); } + /** + * To get all the jobs specified by the given parameters + */ + public function getJobsByTypeStatus($type, $status) + { + $this->_ci->JobsQueueModel->resetQuery(); + + $this->_ci->JobsQueueModel->addOrder('creationtime', 'DESC'); + + return $this->_ci->JobsQueueModel->loadWhere(array('status' => $status, 'type' => $type)); + } + /** * To get all the jobs specified by the given parameters */