diff --git a/application/controllers/jobs.php b/application/controllers/jobs.php index 35d0f39..8d5de28 100644 --- a/application/controllers/jobs.php +++ b/application/controllers/jobs.php @@ -7,6 +7,7 @@ class Jobs extends CI_Controller { */ public function __construct() { parent::__construct(); + $this->load->model('job'); // load language file $this->lang->load(strtolower($this->router->class)); @@ -49,23 +50,20 @@ class Jobs extends CI_Controller { ) )); } - - public function listResultsNotSeen() { - $query = $this->db->order_by('started_at', 'asc') - ->get_where('jobs', array('started_by' => $this->session->userdata('user_id'), 'seen' => '0')); - $count = $query->num_rows(); - $jobs = $query->result_array(); - - for($i=0; $idb->select('name')->get_where('projects', array('id' => $jobs[$i]['project_id']))->row()->name; - } + + /** + * Get a list of results that the owner has not yet seen. + * @todo not yet verified + */ + public function get_unseen_results() { + $results = $this->job->get_unseen_results(); $this->output ->set_content_type('application/json') ->set_output(json_encode( array( - 'count' => $count, - 'jobs' => $jobs + 'count' => count($results), + 'results' => $results ) )); } diff --git a/application/models/job.php b/application/models/job.php index de6d45e..14f7cc8 100644 --- a/application/models/job.php +++ b/application/models/job.php @@ -20,4 +20,19 @@ class Job extends CI_Model { $this->db->escape($progress).$finished_at. " WHERE `id`=". $this->db->escape($job_id)); } + + /** + * Get a list of results that the owner has not yet seen. + */ + public function get_unseen_results() { + $query = $this->db->order_by('started_at', 'asc') + ->get_where('jobs', array('started_by' => $this->session->userdata('user_id'), 'seen' => '0')); + $jobs = $query->result_array(); + + for($i=0; $idb->select('name')->get_where('projects', array('id' => $jobs[$i]['project_id']))->row()->name; + } + + return $jobs; + } }