function tripal_get_active_jobs
2.x tripal_core.jobs.api.inc | tripal_get_active_jobs($modulename = NULL) |
3.x tripal.jobs.api.inc | tripal_get_active_jobs($modulename = NULL) |
Returns a list of jobs that are active.
Parameters
$modulename: Limit the list returned to those that were added by a specific module. If no module name is provided then all active jobs are returned.
Return value
An array of objects where each object describes a tripal job. If no jobs were found then an empty array is returned. Each object will have the following members:
- job_id: The unique ID number for the job.
- uid: The ID of the user that submitted the job.
- job_name: The human-readable name of the job.
- modulename: The name of the module that submitted the job.
- callback: The callback function to be called when the job is run.
- arguments: An array of arguments to be passed to the callback function.
- progress: The percent progress of completion if the job is running.
- status: The status of the job: Waiting, Completed, Running or Cancelled.
- submit_date: The UNIX timestamp when the job was submitted.
- start_time: The UNIX timestamp for when the job started running.
- end_time: The UNIX timestampe when the job completed running.
- error_msg: Any error message that occured during execution of the job.
- prirotiy: The execution priority of the job (value between 1 and 10)
Related topics
1 call to tripal_get_active_jobs()
- tripal_get_module_active_jobs in legacy/
tripal_core/ api/ tripal_core.DEPRECATED.inc
1 string reference to 'tripal_get_active_jobs'
- tripal_get_module_active_jobs in legacy/
tripal_core/ api/ tripal_core.DEPRECATED.inc
File
- tripal/
api/ tripal.jobs.api.inc, line 520 - Tripal offers a job management subsystem for managing tasks that may require an extended period of time for completion.
Code
function tripal_get_active_jobs($modulename = NULL) {
$query = db_select('tripal_jobs', 'TJ')
->fields('TJ', array('job_id', 'uid', 'job_name', 'modulename', 'callback',
'arguments', 'progress', 'status', 'submit_date', 'start_time',
'end_time', 'error_msg', 'priority'));
if ($modulename) {
$query->where(
"TJ.modulename = :modulename and NOT (TJ.status = 'Completed' or TJ.status = 'Cancelled')",
array(':modulename' => $modulename)
);
}
$results = $query->execute();
$jobs = array();
while ($job = $results->fetchobject()) {
$jobs->arguments = unserialize($job->arguments);
$jobs[] = $job;
}
return $jobs;
}