Improve job daemon to update dashboard
This commit is contained in:
@@ -61,13 +61,23 @@ class Ajax extends CI_Controller {
|
||||
$unseen = $this->job->getUnseenResults();
|
||||
|
||||
foreach ($unseen as $job) {
|
||||
$this->job->update($job['id'], array('seen' => 1));
|
||||
if ($job['notified'] == 0) {
|
||||
$this->job->update($job['id'], array('notified' => 1));
|
||||
|
||||
$experiment = anchor('experiments/detail/' . $job['experiment_id'], $job['experiment_name']);
|
||||
$project = anchor('projects/detail/' . $job['project_id'], $job['project_name']);
|
||||
$experiment = anchor('experiments/detail/' . $job['experiment_id'], $job['experiment_name']);
|
||||
$project = anchor('projects/detail/' . $job['project_id'], $job['project_name']);
|
||||
|
||||
$this->messages->add(sprintf(_('The job for %s in project %s is ready.'), $experiment, $project), 'success');
|
||||
$this->messages->add(sprintf(_('The job for %s in project %s is ready.'), $experiment, $project), 'success');
|
||||
}
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'jobs_finished' => count($unseen),
|
||||
'jobs_running' => $this->job->countRunning(),
|
||||
'jobs_pending' => $this->job->countPending(),
|
||||
);
|
||||
|
||||
$this->output->set_output(json_encode($data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,26 +50,30 @@ class Dashboard extends CI_Controller {
|
||||
|
||||
$tpl['recent_buttons'] = array(
|
||||
array(
|
||||
'count' => 4,
|
||||
'count' => $this->job->countUnseenResults(),
|
||||
'text' => _('Jobs finished'),
|
||||
'id' => 'jobs_finished',
|
||||
'title' => sprintf(_('%d jobs finished recently'), 3),
|
||||
'target' => '#',
|
||||
),
|
||||
array(
|
||||
'count' => 2,
|
||||
'count' => 0,
|
||||
'text' => _('Newly shared projects'),
|
||||
'id' => 'shared_projects',
|
||||
'title' => sprintf(_('You were invited to join %d projects'), 2),
|
||||
'target' => '#',
|
||||
),
|
||||
array(
|
||||
'count' => 1,
|
||||
'count' => $this->job->countRunning(),
|
||||
'text' => _('Job running'),
|
||||
'id' => 'jobs_running',
|
||||
'title' => sprintf(_('There is %d job currently running'), 1),
|
||||
'target' => '#',
|
||||
),
|
||||
array(
|
||||
'count' => 2,
|
||||
'count' => $this->job->countPending(),
|
||||
'text' => _('Jobs pending'),
|
||||
'id' => 'jobs_pending',
|
||||
'title' => sprintf(_('There are %2 job currently pending'), 1),
|
||||
'target' => '#',
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user