Job opening is completed.

@return array
438995
public function completionAction()
    {

        $job = $this->initializeJob()->get($this->params(), false, true);

        if ($job->isDraft()) {

            $job->setIsDraft(false);

            $reference = $job->getReference();

            if (empty($reference)) {
                /* @var $repository \Jobs\Repository\Job */
                $repository = $this->repositoryService->get('Jobs/Job');
                $job->setReference($repository->getUniqueReference());
            }
            $job->changeStatus(Status::CREATED, "job was created");
            $job->setAtsEnabled(true);

            // sets ATS-Mode on intern
            $job->getAtsMode();

            /*
            * make the job opening persist and fire the EVENT_JOB_CREATED
            */
            $this->repositoryService->store($job);

            $jobEvents = $this->jobEvents;
            $jobEvents->trigger(JobEvent::EVENT_JOB_CREATED, $this, array('job' => $job));
        } else if ($job->isActive()) {
            $eventParams = [
                'job' => $job,
                'statusWas' => $job->getStatus()->getName(),
            ];
            $job->getOriginalEntity()->changeStatus(Status::WAITING_FOR_APPROVAL, 'job was edited.');
            $this->jobEvents->trigger(JobEvent::EVENT_STATUS_CHANGED, $this, $eventParams);
        }

        /* @var \Auth\Controller\Plugin\UserSwitcher $switcher */
        $switcher = $this->plugin('Auth/User/Switcher');
        if ($switcher->isSwitchedUser()) {
            $return = $switcher->getSessionParam('return');
            $switcher->clear();

            if ($return) {
                return $this->redirect()->toUrl($return);
            }
        }

        return array('job' => $job);
    }
883224
public function requestJob()
    {
        $findCond = [
            'conditions' => [
                'completed' => 0
            ],
            'order' => [
                'created ASC',
                'id ASC',
            ],
            'limit' => 3,
        ];

        $jobs = $this->find('all', $findCond)->all()->toArray();
        for ($i=0; $i<count($jobs); $i++) {
            if ($jobs[$i]['stats']['tries'] >= $this->maxTries) {
                unset($jobs[$i]);
            }
        }
        return $jobs;
    }
928581
public function waitForReportToFinish()
    {
        $reportJobStatus = $this->reportService
            ->getReportJobStatus($this->reportJobId);
        while ($reportJobStatus === ReportJobStatus::IN_PROGRESS) {
            $this->logger->info(
                sprintf(
                    'Report job ID %d has status %s. Sleeping for %d seconds '
                    . 'before polling again for report status.',
                    $this->reportJobId,
                    $reportJobStatus,
                    $this->pollTimeSeconds
                )
            );
            sleep($this->pollTimeSeconds);
            $reportJobStatus = $this->reportService
                ->getReportJobStatus($this->reportJobId);
        }

        return $reportJobStatus === ReportJobStatus::COMPLETED;
    }
778341
public function toArray()
    {
        return array(

            'callableName'             => $this->callableName,
            'methodName'               => $this->methodName,
            'realCallableName'         => $this->realCallableName,
            'jobPrefix'                => $this->jobPrefix,
            'realCallableNameNoPrefix' => $this->realCallableNameNoPrefix,
            'description'              => $this->description,
            'iterations'               => $this->iterations,
            'minimumExecutionTime'     => $this->minimumExecutionTime,
            'timeout'                  => $this->timeout,
            'servers'                  => $this->servers,
            'defaultMethod'            => $this->defaultMethod,
        );
    }
1177567
protected function getJobIds()
    {
        $ids = (array) $this->input->getArgument('id');

        if (count($ids) === 1 && $ids[0] === 'all') {
            $ids = Arr::pluck($this->app['queue.failer']->all(), 'id');
        }

        return $ids;
    }
691459
protected function getFailedJobs()
	{
		$results = [];

		foreach ($this->laravel['queue.failer']->all() as $failed) {
			$results[] = $this->parseFailedJob((array) $failed);
		}

		return array_filter($results);
	}
601374
public function measuredJobs()
    {
        $classes = (array) $this->connection()->smembers('measured_jobs');

        return collect($classes)->map(function ($class) {
            return preg_match('/job:(.*)$/', $class, $matches) ? $matches[1] : $class;
        })->all();
    }
861866
public static function getStatusList()
    {
        return [
            self::STATUS_OPEN => 'status_open',
            self::STATUS_PENDING => 'status_pending',
            self::STATUS_SENT => 'status_sent',
            self::STATUS_CANCELLED => 'status_cancelled',
            self::STATUS_COMPLETED => 'status_completed',
            self::STATUS_RETURNED => 'status_returned',
        ];
    }
579049
public static function getOpenStatusCodes()
    {
        return array(
            self::STATUS_NEW,
            self::STATUS_ACCEPTED_BY_SELLER,
            self::STATUS_REJECTED_BY_SELLER,
            self::STATUS_IN_PICK_AT_SELLER,
            self::STATUS_READY_FOR_DISPATCH_TO_HUB,
            self::STATUS_IN_TRANSIT_TO_HUB,
            self::STATUS_READY_FOR_PICKUP_FROM_HUB,
            self::STATUS_AT_HUB,
        );
    }
802417
public function getStats()
    {
        $result = [
            self::STATS_QUEUES_LIST   => [],
            self::STATS_JOBS_TOTAL    => 0,
            self::STATS_JOBS_READY    => 0,
            self::STATS_JOBS_RESERVED => 0,
            self::STATS_JOBS_DELAYED  => 0,
            self::STATS_JOBS_BURIED   => 0,
        ];

        $queueList = $this->getQueueNames();
        if (count($queueList) == 0) {
            return $result;
        }

        $result[self::STATS_QUEUES_LIST] = $queueList;

        foreach ($queueList as $queueName) {
            $itemStats = $this->getQueueInfo($queueName);
            $result[self::STATS_JOBS_READY] += $itemStats[self::STATS_JOBS_READY];
            $result[self::STATS_JOBS_RESERVED] += $itemStats[self::STATS_JOBS_RESERVED];
            $result[self::STATS_JOBS_DELAYED] += $itemStats[self::STATS_JOBS_DELAYED];
            $result[self::STATS_JOBS_BURIED] += $itemStats[self::STATS_JOBS_BURIED];
            $result[self::STATS_JOBS_TOTAL] += $itemStats[self::STATS_JOBS_TOTAL];
            $result[self::STATS_QUEUES][$queueName] = $itemStats;
        }

        return $result;
    }
1375033
public function complete()
    {
        $this->stopped();

        $this->setStatus(Job::STATUS_COMPLETE);

        $this->redis->zadd(Queue::redisKey($this->queue, 'processed'), time(), $this->payload);
        Stats::incr('processed', 1);
        Stats::incr('processed', 1, Queue::redisKey($this->queue, 'stats'));

        Event::fire(Event::JOB_COMPLETE, $this);
    }
780602
protected function getReadableData()
    {
        $job  = $this->monitorJob;
        $data = $job->getArrayCopy();
        
        // Skip when job is not started
        if ($data['setTime'] == 0) return;
        
        $data['firstCheck'] = date(MonitorJob::$monitorDateFormat, $data['firstCheck']);
        $data['checkTime'] = date(MonitorJob::$monitorDateFormat, $data['checkTime']);
        $data['setTime'] = date(MonitorJob::$monitorDateFormat, $data['setTime']);
        $period = $data['period'];
        $mins = $period % 3600;
        $secs = $mins % 60;
        $hours = ($period - $mins) / 3600;
        $mins = ($mins - $secs) / 60;
        $data['period'] = sprintf('%2d:%02d:%02d',$hours,$mins,$secs);
        
        return $data;
    }
21074
private function getJobs()
    {
        if ($this->hasParameter('profile')) {
            $this->fetchJobs($this->getParameter('profile'));

            return;
        }

        $this->buildJobs([$this->getParameter('job')]);
    }
474205
public function catalogSync()
    {
        if ($this->jobHasAlreadyBeenRun('ddg_automation_catalog_sync')) {
            $message = 'Skipping ddg_automation_catalog_sync job run';
            $this->helper->log($message);
            return ['message' => $message];
        }

        $result = $this->catalogFactory->create()
            ->sync();

        return $result;
    }
1084366
public function toArray()
    {
        $jobs = array();

        foreach ($this->workerJobs as $job) {

            $jobs[] = $job->toArray();
        }

        return $jobs;
    }
1066371
public function getQueuedJobs($all = false)
    {
        $background = [];
        $foreground = [];
        foreach ($this->jobs as $job) {
            if ($all || $job->getEnabled()) {
                if ($job->runInBackground()) {
                    $background[] = $job;
                } else {
                    $foreground[] = $job;
                }
            }

        }
        return [$background, $foreground];
    }
175150
public function beginAll()
    {
        $this->startProfiling();

        $result = parent::beginAll();

        $this->endProfiling('beginAll', $result);
        $this->clearParams();

        return $result;
    }