* Either returns the number of ALL pending tasks, or the number of pending tasks of the passed Type
*
* @param string $type jobType to Count
* @return integer
*/
publicfunctiongetLength($type = null) {
$findConf = array(
'conditions' => array(
'completed' => null
)
);
if ($type != NULL) {
$findConf['conditions']['jobtype'] = $type;
}
return$this->find('count', $findConf);
}
/**
* Return a list of all jobtypes in the Queue.
*
* @return array
*/
publicfunctiongetTypes() {
$findConf = array(
'fields' => array(
'jobtype'
),
'group' => array(
'jobtype'
)
);
return$this->find('list', $findConf);
}
/**
* Return some statistics about finished jobs still in the Database.
* @return array
*/
publicfunctiongetStats() {
$findConf = array(
'fields' => array(
'jobtype,count(id) as num, AVG(UNIX_TIMESTAMP(completed)-UNIX_TIMESTAMP(created)) AS alltime, AVG(UNIX_TIMESTAMP(completed)-UNIX_TIMESTAMP(fetched)) AS runtime, AVG(UNIX_TIMESTAMP(fetched)-IF(notbefore is null,UNIX_TIMESTAMP(created),UNIX_TIMESTAMP(notbefore))) AS fetchdelay'
'(CASE WHEN ' . $this->alias . '.notbefore > NOW() THEN \'NOT_READY\' WHEN ' . $this->alias . '.fetched IS NULL THEN \'NOT_STARTED\' WHEN ' . $this->alias . '.fetched IS NOT NULL AND ' . $this->alias . '.completed IS NULL AND ' . $this->alias . '.failed = 0 THEN \'IN_PROGRESS\' WHEN ' . $this->alias . '.fetched IS NOT NULL AND ' . $this->alias . '.completed IS NULL AND ' . $this->alias . '.failed > 0 THEN \'FAILED\' WHEN ' . $this->alias . '.fetched IS NOT NULL AND ' . $this->alias . '.completed IS NOT NULL THEN \'COMPLETED\' ELSE \'UNKNOWN\' END) AS status',