/** * @return \Illuminate\Contracts\View\View */ public function index() { $jobs = $this->jobRepo->latest(10); $issues = $this->jobRepo->latest(25, [['status', '=', 'error']], 'id', 'desc'); $logs = $this->logRepo->latest(25, [], 'id', 'desc'); return \View::make('connector::dashboard.index', ['jobs' => $jobs, 'issues' => $issues, 'logs' => $logs]); }
/** * @param Job $syncJob Laravel queue job * @param $arguments * @return bool * @throws \Unifact\Connector\Exceptions\HandlerException */ public function fire(Job $syncJob, $arguments) { try { $job = $this->jobRepo->findById($arguments['job_id']); $job->setPreviousStatus($arguments['previous_status']); $handler = forward_static_call([$job->handler, 'make']); $this->logger->debug("Preparing Job.."); if (!$handler->prepare()) { $this->logger->error('Handler returned FALSE in prepare() method, see log for details'); // delete Laravel queue job $syncJob->delete(); return false; } $this->logger->debug("Handling Job.."); if ($handler->handle($job) === false) { $this->logger->error('Handler returned FALSE in handle() method, see log for details'); // delete Laravel queue job $syncJob->delete(); return false; } $this->logger->debug("Completing Job.."); $handler->complete(); $this->logger->info('Finished Job successfully'); } catch (\Exception $e) { $this->oracle->exception($e); $this->logger->error('Exception was thrown in JobQueueHandler::fire method.'); $this->jobRepo->update($arguments['job_id'], ['status' => 'error']); // delete Laravel queue job $syncJob->delete(); return false; } // delete Laravel queue job $syncJob->delete(); return true; }
/** * @param $jobId * @param $stageId * @return \Illuminate\Contracts\View\View */ public function show($jobId, $stageId) { $stage = $this->stageRepo->findById($stageId); $previous = $this->stageRepo->getPrecedingStage($stage); if ($previous === null) { $previous = $this->jobRepo->findById($stage->job_id); } $logs = $this->logRepo->filter([['job_id', $stage->job_id], ['stage', $stage->stage]], 'id'); return \View::make('connector::stage.show', ['stage' => new StagePresenter($stage), 'previous' => $previous, 'logs' => $logs]); }
/** * * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse */ public function search() { $results = new Collection(); $reference = \Request::get('reference'); $data = \Request::get('data'); $dateFrom = \Request::get('from'); $dateTo = \Request::get('to'); $filters = []; $time = ' 23:59:59'; if (!empty($dateFrom)) { $filters[] = ['created_at', '>=', $dateFrom . $time]; } if (!empty($dateTo)) { $filters[] = ['created_at', '<=', $dateTo . $time]; } $jobs = []; $stages = []; $query = ""; $search = false; $jobFilters = $filters; $stageFilters = $filters; if (!empty($reference)) { $jobFilters[] = ['reference', $reference]; $search = true; } if (!empty($data)) { $jobFilters[] = ['data', 'LIKE', '%' . $data . '%']; $stageFilters[] = ['data', 'LIKE', '%' . $data . '%']; $search = true; } if (sizeof($filters) > 0) { $search = true; } if ($search === false) { return \Redirect::route('connector.dashboard.index'); } $jobs = $this->jobRepo->filter($jobFilters); if (!empty($data)) { $stages = $this->stageRepo->filter($stageFilters); } else { $stages = []; } foreach ($jobs as $job) { $results->push(new JobPresenter($job)); } foreach ($stages as $stage) { $results->push(new StagePresenter($stage)); } $results = $results->sort(function ($a, $b) { return strtotime($a->created_at) > strtotime($b->created_at) ? 1 : 0; }); return \View::make('connector::search.results', ['results' => $results]); }
public function update($id) { $job = $this->jobRepo->findById($id); if (!empty(\Request::get('save_restart'))) { $this->jobRepo->update($id, ['data' => \Request::get('data'), 'status' => Job::STATUS_RESTART]); } elseif (!empty(\Request::get('restart'))) { $this->jobRepo->update($id, ['status' => Job::STATUS_RESTART]); } elseif (!empty(\Request::get('retry'))) { $this->jobRepo->update($id, ['status' => Job::STATUS_RETRY]); } return \Redirect::route('connector.jobs.show', [$id]); }
public function fire() { $days = $this->argument('days'); try { if (!is_numeric($days)) { throw new \Exception("days must be numeric"); } $this->jobRepo->clean($days); $this->logRepo->clean($days); } catch (\Exception $e) { $this->out('Error cleaning database: ' . $e->getMessage()); } }
/** * @param $stage */ protected function deleteFailedStages($stage) { $deletes = $this->stageRepo->filter([['job_id', $stage->job_id], ['id', '>', $stage->id]]); foreach ($deletes as $delete) { $this->jobRepo->delete($delete->id); } }
/** * @param $status * @return \Unifact\Connector\Models\Job[] */ protected function getJobsWithStatus($status) { return $this->jobRepo->latest(100, [['status', $status]], 'id', 'asc'); }