function tripal_jobs_report
2.x tripal_core.jobs.inc | tripal_jobs_report() |
3.x tripal.jobs.inc | tripal_jobs_report() |
1.x jobs.inc | tripal_jobs_report() |
Returns the Tripal Job Report
Return value
The HTML to be rendered which describes the job report
Related topics
1 string reference to 'tripal_jobs_report'
- tripal_core_menu in tripal_core/
tripal_core.module - Implements hook_menu(). Defines all menu items needed by Tripal Core
File
- tripal_core/
includes/ jobs.inc, line 73 - Contains functions related to the display of Tripal jobs in a Tripal website.
Code
function tripal_jobs_report() {
// run the following function which will
// change the status of jobs that have errored out
tripal_jobs_check_running();
$job_status = $_SESSION['tripal_job_filter']['job_status'];
$job_name = $_SESSION['tripal_job_filter']['job_name'];
$sql = "
SELECT
TJ.job_id,TJ.uid,TJ.job_name,TJ.modulename,TJ.progress,
TJ.status as job_status, TJ,submit_date,TJ.start_time,
TJ.end_time,TJ.priority,U.name as username
FROM {tripal_jobs} TJ
INNER JOIN {users} U on TJ.uid = U.uid
WHERE 1=1
";
$args = array();
if ($job_status) {
$sql .= "AND TJ.status = '%s' ";
$args[] = $job_status;
}
if ($job_name) {
$sql .= "AND TJ.job_name like '%%%s%%'";
$args[] = $job_name;
}
$sql .= "ORDER BY job_id DESC";
$jobs = pager_query($sql, 25, 0, "SELECT count(*) FROM ($sql) as t1", $args);
$header = array(
'Job ID',
'User',
'Job Name',
array('data' => 'Dates', 'style' => "white-space: nowrap"),
'Priority',
'Progress',
'Status',
'Action');
$rows = array();
// iterate through the jobs
while ($job = db_fetch_object($jobs)) {
$submit = tripal_jobs_get_submit_date($job);
$start = tripal_jobs_get_start_time($job);
$end = tripal_jobs_get_end_time($job);
$cancel_link = '';
if ($job->start_time == 0 and $job->end_time == 0) {
$cancel_link = "<a href=\"" . url("admin/tripal/tripal_jobs/cancel/" . $job->job_id) . "\">Cancel</a><br />";
}
$rerun_link = "<a href=\"" . url("admin/tripal/tripal_jobs/rerun/" . $job->job_id) . "\">Re-run</a><br />";
$view_link = "<a href=\"" . url("admin/tripal/tripal_jobs/view/" . $job->job_id) . "\">View</a>";
$rows[] = array(
$job->job_id,
$job->username,
$job->job_name,
"Submit Date: $submit<br>Start Time: $start<br>End Time: $end",
$job->priority,
$job->progress . '%',
$job->job_status,
"$cancel_link $rerun_link $view_link",
);
}
// create the report page
$output .= "Waiting jobs are executed first by priority level (the lower the " .
"number the higher the priority) and second by the order they " .
"were entered";
$output .= drupal_get_form('tripal_jobs_report_form');
$output .= theme('table', $header, $rows);
$output .= theme_pager();
return $output;
}