Show recent jobs in projects

This commit is contained in:
Eike Foken
2011-08-30 23:56:56 +02:00
parent d1dc5581ee
commit 24808081fd
3 changed files with 41 additions and 18 deletions

View File

@@ -116,6 +116,7 @@ class Projects extends CI_Controller {
*/
public function detail($id) {
$this->load->helper('typography');
$this->load->model('job');
$project = $this->project->getById($id);
if (!$project) {
@@ -125,7 +126,7 @@ class Projects extends CI_Controller {
$data['project'] = $project;
$data['trials'] = $this->trial->getByProjectId($id);
$data['jobsDone'] = null;
$data['jobs'] = $this->job->getRecent();
$this->load->view('projects/detail', $data);
}

View File

@@ -28,10 +28,10 @@
class Job extends CI_Model {
/**
* Create a new job.
* Creates a new job.
*
* @param array $data the data of the new job
* @return bool was the insert successful
* @param array $data The data of the new job
* @return boolean Returns TRUE if the insert was successful.
*/
public function create($data) {
$this->load->helper('date');
@@ -49,18 +49,18 @@ class Job extends CI_Model {
}
/**
* Delete a job.
* @param string the job id to delete
* @return bool was the deletion successful
* Deletes a job.
* @param string The job ID to delete
* @return boolean Returns TRUE if the deletion was successful.
*/
public function delete($job_id) {
return $this->db->delete('jobs', array('id' => $job_id));
}
/**
* Update the details of a given job.
* Updates the details of a given job.
*
* @param string $job_id The job's id you want to update.
* @param string $job_id The job ID you want to update
* @param integer $data The data of the job.
*/
public function update($job_id, $data) {
@@ -68,7 +68,27 @@ class Job extends CI_Model {
}
/**
* Get a list of results that the owner has not yet seen.
* Gets a list of recent jobs.
*
* @param string $projectId The project's ID you want to get the jobs for
* @return array
*/
public function getRecent($projectId = '') {
$this->db->select('jobs.*, trials.project_id, trials.name');
$this->db->join('trials', 'jobs.trial_id = trials.id', 'left');
$this->db->where('finished_at', 0);
if (!empty($projectId)) {
$this->db->where('project_id', $projectId);
}
return $this->db->get('jobs')->result_array();
}
/**
* Gets a list of results that the owner has not yet seen.
*
* @return array
*/
public function getUnseenResults() {
$query = $this->db->order_by('started_at', 'asc')
@@ -83,7 +103,9 @@ class Job extends CI_Model {
}
/**
* Get a list of jobs that have not yet started running.
* Gets a list of jobs that have not yet started running.
*
* @return mixed
*/
public function getWaitingJob() {
$query = $this->db->order_by('created_at', 'asc')->get_where('jobs', array('started_at' => '0000-00-00 00:00:00'), 1);

View File

@@ -83,21 +83,21 @@
<thead>
<tr>
<th scope="col"><?=_('Trial');?></th>
<th scope="col"><?=_('Finished');?></th>
<th scope="col"><?=_('Started');?></th>
<th scope="col"><?=_('Actions');?></th>
</tr>
</thead>
<tbody>
<?php
if (count($jobsDone) > 0):
foreach ($jobsDone as $job):
if (count($jobs) > 0):
foreach ($jobs as $job):
?>
<tr>
<td>Versuchsname</td>
<td>Heute, 09:32</td>
<td><?=$job['name'];?></td>
<td><?=$job['started_at'];?></td>
<td>
<a href="<?=site_url('trials/results/' . $trial['id']);?>" title="<?= sprintf(_('Show results for the trial &quot;%s&quot;'), $trial['name']);?>"><?=_('Show results');?></a> |
<a href="<?=site_url('trials/edit/' . $trial['id']);?>" title="<?= sprintf(_('Edit trial &quot;%s&quot;'), $trial['name']);?>"><?=_('Edit');?></td>
<a href="<?=site_url('trials/results/' . $job['id']);?>" title="<?= sprintf(_('Show results for the trial &quot;%s&quot;'), $job['name']);?>"><?=_('Show results');?></a> |
<a href="<?=site_url('trials/edit/' . $job['id']);?>" title="<?= sprintf(_('Edit trial &quot;%s&quot;'), $job['name']);?>"><?=_('Edit');?></td>
</tr>
<?php
endforeach;