public function testJobBuffer() { $jobBuffer = new JobBuffer(); $this->assertEquals(0, $jobBuffer->getTotalJobsCount()); $this->assertEquals(0, $jobBuffer->getBufferedJobsCount()); $job = Job::create('http://any-site.com', 'any-script.js'); $jobBuffer->addJob($job); $this->assertEquals(1, $jobBuffer->getTotalJobsCount()); $this->assertEquals(1, $jobBuffer->getBufferedJobsCount()); $job2 = Job::create('http://any-site-2.com', 'any-script.js'); $jobBuffer->addJob($job2); $this->assertEquals(2, $jobBuffer->getTotalJobsCount()); $this->assertEquals(2, $jobBuffer->getBufferedJobsCount()); $jobBuffer->addJob($job2); $this->assertEquals(2, $jobBuffer->getTotalJobsCount()); $this->assertEquals(2, $jobBuffer->getBufferedJobsCount()); $firstJob = $jobBuffer->getJob(); $this->assertEquals($job, $firstJob); $this->assertEquals(2, $jobBuffer->getTotalJobsCount()); $this->assertEquals(1, $jobBuffer->getBufferedJobsCount()); $secondJob = $jobBuffer->getJob(); $this->assertEquals($job2, $secondJob); $this->assertEquals(2, $jobBuffer->getTotalJobsCount()); $this->assertEquals(0, $jobBuffer->getBufferedJobsCount()); $this->assertNull($jobBuffer->getJob()); }
public function testOriginNode() { $job = Job::create(['id' => 'D-dcb833cf-8YL1NT17e9+wsA/09NqxscQI-05a1', 'body' => '']); $this->assertEquals('dcb833cf', $job->getOriginNode()); $job = Job::create(['body' => '']); $this->assertNull($job->getOriginNode()); }
public function actionCreate() { //validate form //$this->prepareForm(); $loggedUser = new EmployerController(); if ($loggedUser->me == "guest") { return; } $me = $loggedUser->me; if (isset($_POST['create'])) { $job = new Job($_POST); $job->postedBy = $me->userID; $job->skills = $_POST['skills']; $job->type = $_POST['type'] ? "Paid" : "Non-paid"; if ($job->create() === true) { //go to user projects $_SESSION['error'] = "Created"; } else { $_SESSION['error'] = "Unable tp create job. Please try later"; } } $page = "new"; include __VIEWPATH__ . "user/_dashboard.php"; }
if (!empty($_POST['cc'])) { $data['contact_carbon_copy'] = $_POST['cc']; } $salary_end = $_POST['salary_end']; if ($salary_end <= 0) { $salary_end = $_POST['salary']; $data['salary_end'] = 'NULL'; } $data['potential_reward'] = Job::calculate_potential_reward_from($salary_end, $_POST['employer']); // Check whether employer's account is ready. if ($data['potential_reward'] <= 0) { echo '-1'; exit; } if ($id <= 0) { if ($job->create($data) == false) { echo "ko"; exit; } } else { if ($job->update($data) == false) { echo "ko"; exit; } } echo "ok"; exit; } if ($_POST['action'] == 'close') { if (!isset($_POST['payload'])) { echo "ko";
/** * Create a new job and save it to the specified queue. * * @param string $queue The name of the queue to place the job in. * @param string $class The name of the class that contains the code to execute the job. * @param array $args Any optional arguments that should be passed when the job is executed. * @param boolean $trackStatus Set to true to be able to monitor the status of a job. * * @return string */ public static function enqueue($queue, $class, $args = array(), $trackStatus = false) { $result = Job::create($queue, $class, $args, $trackStatus); if ($result) { Event::trigger('afterEnqueue', array('class' => $class, 'args' => $args, 'queue' => $queue)); } return $result; }
public static function handleSynchronizeRequest() { // read request/response configuration $pretend = !empty($_REQUEST['pretend']); if (static::peekPath() == 'json' || static::peekPath() == 'text') { static::$responseMode = static::shiftPath(); } if ($jobHandle = static::shiftPath()) { if (!($Job = Job::getByHandle($jobHandle))) { return static::throwNotFoundError('Job not found'); } if (static::$synchronizeRequiredAccountLevel) { $GLOBALS['Session']->requireAccountLevel(static::$synchronizeRequiredAccountLevel); } if (static::peekPath() == 'log') { $logPath = $Job->getLogPath() . '.bz2'; if (file_exists($logPath)) { header('Content-Type: application/json'); header(sprintf('Content-Disposition: attachment; filename="%s-%u.json"', $Job->Connector, $Job->ID)); passthru("bzcat {$logPath}"); exit; } else { return static::throwNotFoundError('Log not available'); } } return static::respond('jobStatus', array('data' => $Job)); } // authenticate and create job or copy template if (!empty($_REQUEST['template'])) { $TemplateJob = Job::getByHandle($_REQUEST['template']); if (!$TemplateJob || $TemplateJob->Status != 'Template' || $TemplateJob->Connector != get_called_class()) { return static::throwNotFoundError('Template job not found'); } $Job = Job::create(array('Connector' => $TemplateJob->Connector, 'Template' => $TemplateJob, 'Config' => $TemplateJob->Config)); } else { if (static::$synchronizeRequiredAccountLevel) { $GLOBALS['Session']->requireAccountLevel(static::$synchronizeRequiredAccountLevel); } $Job = Job::create(array('Connector' => get_called_class(), 'Config' => static::_getJobConfig($_REQUEST))); if (!empty($_REQUEST['createTemplate'])) { if ($pretend) { return static::throwInvalidRequestError('Cannot combine pretend and createTemplate'); } $Job->Status = 'Template'; $Job->save(); return static::respond('templateCreated', array('data' => $Job)); } } // show template if not a post if ($_SERVER['REQUEST_METHOD'] != 'POST') { return static::respond('createJob', array('data' => $Job, 'templates' => Job::getAllByWhere(array('Status' => 'Template', 'Connector' => get_called_class())))); } // save job in pending state before starting if (!$pretend) { $Job->save(); } // close connection to client if (!empty($_REQUEST['fork'])) { header('Location: ' . static::_getConnectorBaseUrl(true) . '/' . $Job->Handle, true, 201); print json_encode(array('data' => $Job->getData())); fastcgi_finish_request(); } // update execution time limit set_time_limit(static::$synchronizeTimeLimit); // execute synchronization try { $success = static::synchronize($Job, $pretend); } catch (Exception $e) { $Job->logException($e); $success = false; } if (!$success) { $Job->Status = 'Failed'; } // save job if not pretend if (!$pretend) { $Job->save(); $Job->writeLog(); // email report if (!empty($Job->Config['reportTo'])) { \Emergence\Mailer\Mailer::sendFromTemplate($Job->Config['reportTo'], 'syncronizeComplete', array('Job' => $Job, 'connectorBaseUrl' => static::_getConnectorBaseUrl(true))); } } // all done, respond return static::respond('syncronizeComplete', array('data' => $Job, 'success' => $success, 'pretend' => $pretend)); }
</p><p style="font-weight: bold;">Add another new job... </p><p><?php $job = new Job(); $date = date('Y-m-d H:i:s'); $expiry_date = sql_date_add($date, 30, 'day'); $data = array(); $data['employer'] = 'acme123'; $data['industry'] = '2'; $data['country'] = 'SG'; $data['currency'] = 'MYR'; $data['salary'] = '3200'; $data['salary_negotiable'] = 'N'; $data['created_on'] = $date; $data['expire_on'] = $expiry_date; $data['title'] = "Some lame job"; $data['description'] = "blahlelelll blah... some job descriptions goes here"; if ($job->create($data)) { echo "This job gets the ID of <b>" . $job->getId() . "</b><br><br>"; print_array($job->get()); } else { echo "failed"; exit; } ?> </p><p style="font-weight: bold;">Get all jobs... </p><p><?php $jobs = $job->find(array('columns' => 'id')); echo "There are " . count($jobs) . " jobs in the database.<br><br>"; ?> </p><p style="font-weight: bold;">Update 1st job... </p><p><?php echo $first_job_id . '<br/>'; $job = new Job($first_job_id); $data = array();
$data['employer'] = $_POST['employer']; $data['industry'] = $_POST['industry']; $data['country'] = $_POST['country']; $data['state'] = $_POST['state']; $data['salary'] = $_POST['salary']; $data['salary_end'] = $_POST['salary_end']; $data['salary_negotiable'] = $_POST['salary_negotiable']; $data['title'] = $_POST['title']; $data['description'] = str_replace(array("\r\n", "\r", "\n"), '<br/>', $_POST['description']); $data['acceptable_resume_type'] = 'A'; $data['closed'] = 'N'; $new_id = 0; if ($id <= 0) { $data['created_on'] = now(); $data['expire_on'] = sql_date_add($data['created_on'], 30, 'day'); if (($new_id = $job->create($data)) === false) { echo 'ko'; exit; } } else { if ($job->update($data) == false) { echo 'ko'; exit; } } $data = array(); $salary_end = $_POST['salary_end']; if ($salary_end <= 0) { $salary_end = $_POST['salary']; $data['salary_end'] = 'NULL'; }
public function createJob($attributes = array()) { $job = new Job($this->request); $job->create($attributes); return $job; }
public function anyRepost($id) { $job = Job::findOrFail($id)->replicate(); $jobArray = json_decode($job, true); if ($job->job_status_id == JobStatus::$AWARDED) { $jobArray['job_status_id'] = JobStatus::$OPEN; } if (time() <= $job->getStartDateEpoch()) { $jobArray['start_date'] = date("Y-m-d", strtotime("+2 days")); } $jobArray["awardee_id"] = null; $newJob = Job::create($jobArray); return Redirect::action("JobsController@anyDetails", array("id" => $newJob->id)); }