Example #1
0
 /**
  * @param Job $job
  * @return array
  */
 private function _getJobData($job)
 {
     $jobData = array();
     $jobData['id'] = $job->id;
     $jobData['name'] = $job->getName();
     $jobData['url'] = $job->getUrl();
     $jobData['elapsed'] = $job->getElapsedText();
     $jobData['queue_name'] = $job->getQueue()->getName();
     $jobData['queue_url'] = $job->getQueue()->getUrl();
     return $jobData;
 }
Example #2
0
 public function api_canceljob()
 {
     /* @var $job Job */
     $job = new Job($this->args('job_id'));
     if (!$job->isHydrated()) {
         throw new Exception("Job does not exist.");
     }
     if (!$job->getQueue()->isMine()) {
         throw new Exception("This job is not in your queue.");
     }
     //TODO Figure out if this should be implemented
     //if (!$job->canDelete($job))
     //	throw new Exception("You cannot delete this job.");
     Activity::log("cancelled the <strong>" . $job->getName() . "</strong> job via the API.");
     $job->cancelJob();
     return $job->getAPIData();
 }
Example #3
0
 public function testToStringReturnsTheNameOfTheJob()
 {
     $jobMock = new Job('project', 'strategy', uniqid());
     $this->assertEquals($jobMock->getName(), $jobMock->__toString());
 }
Example #4
0
 public function edit()
 {
     $this->assertLoggedIn();
     try {
         //how do we find them?
         if ($this->args('id')) {
             $job = new Job($this->args('id'));
         }
         //did we really get someone?
         if (!$job->isHydrated()) {
             throw new Exception("Could not find that job.");
         }
         if ($job->get('user_id') != User::$me->id) {
             throw new Exception("You do not own this job.");
         }
         if ($job->get('status') != 'available') {
             throw new Exception("You can only edit jobs that have not been taken yet.");
         }
         $this->setTitle('Edit Job - ' . $job->getName());
         $this->set('job', $job);
         //load up our queues.
         $queues = User::$me->getQueues()->getAll();
         foreach ($queues as $row) {
             $q = $row['Queue'];
             $data[$q->id] = $q->getName();
         }
         $this->set('queues', $data);
         if ($this->args('submit')) {
             $queue = new Queue($this->args('queue_id'));
             if (!$queue->canAdd()) {
                 throw new Exception("That is not a valid queue.");
             }
             $job->set('queue_id', $queue->id);
             $job->save();
             Activity::log("edited the job " . $job->getLink() . ".");
             $this->forwardToUrl($job->getUrl());
         }
         //errors?
         if (!$this->get('megaerror')) {
             $this->set('file', $job->getFile());
             $this->set('queue', $job->getQueue());
             $this->set('bot', $job->getBot());
             $this->set('creator', $job->getUser());
         }
     } catch (Exception $e) {
         $this->setTitle('Edit Job - Error');
         $this->set('megaerror', $e->getMessage());
     }
 }
Example #5
0
 public function update(Job $job)
 {
     echo "Человек получил обновление о новой вакансии {$job->getName()} с зарплатой {$job->getSalary()} USD";
     echo '<br>';
 }