diff --git a/application/controllers/ajax.php b/application/controllers/ajax.php index 6b4f6c9..344c9f1 100644 --- a/application/controllers/ajax.php +++ b/application/controllers/ajax.php @@ -66,7 +66,7 @@ class Ajax extends MY_Controller { $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 just finished.'), $experiment, $project), 'success'); } } diff --git a/application/controllers/api.php b/application/controllers/api.php deleted file mode 100644 index 2def42e..0000000 --- a/application/controllers/api.php +++ /dev/null @@ -1,80 +0,0 @@ - - */ -class Api extends CI_Controller { - - /** - * Unloads the session library. - */ - public function __construct() { - parent::__construct(); - - $this->session->sess_destroy(); - unset($this->session); - } - - /** - * Update the state of a given job. - * - * Because we do not want any access from servers we do not trust, - * we need a special secret to authenticate the servers. - * - * @param type $secret The secret to authenticate the server. - * @param type $job_id The job id that is running on the server. - * @param type $state The state of the job. - */ - public function update_job() { - $this->load->model('job'); - - $query = $this->db->get_where('servers', array('secret' => $secret)); - - // if we are in production mode, we do not want to tell the evil hacker - // that he used a wrong secret. That just encourages him. - if($query->num_rows() < 1 && ENVIRONMENT != 'production') { - die("Unauthorized access."); - } - - $this->job->update($job_id, $progress); - } - - /** - * Update the workload of the server. - */ - public function update_workload() { - $this->load->model('server'); - $query = $this->db->get_where('servers', array('secret' => $secret)); - - // if we are in production mode, we do not want to tell the evil hacker - // that he used a wrong secret. That just encourages him. - if($query->num_rows() < 1 && ENVIRONMENT != 'production') { - die("Unauthorized access."); - } - - $this->server->updateWorkload($secret, $workload); - } -} \ No newline at end of file diff --git a/application/controllers/xmlrpc.php b/application/controllers/xmlrpc.php index c6ed96f..dfaf765 100644 --- a/application/controllers/xmlrpc.php +++ b/application/controllers/xmlrpc.php @@ -40,7 +40,6 @@ class Xmlrpc extends MY_Controller { $this->load->model('server'); $this->session->sess_destroy(); - unset($this->session); // unload sessions } /** diff --git a/application/models/job.php b/application/models/job.php index 78b7dbf..5b89bfe 100644 --- a/application/models/job.php +++ b/application/models/job.php @@ -108,6 +108,23 @@ class Job extends CI_Model { return $query->row_array(); } + /** + * Gets a job by its id. + */ + public function getById($job_id) { + $job = $this->db->get_where('jobs', array('id' => $job_id))->row_array(); + return array_map(function($var) { + if ($var['started_at'] == '0000-00-00 00:00:00') { + $var['status'] = 'pending'; + } else if ($var['finished_at'] == '0000-00-00 00:00:00') { + $var['status'] = 'running'; + } else { + $var['status'] = 'complete'; + } + return $var; + }, $job); + } + /** * Gets a list of recent jobs. *