public function cijobsRefresh(JobStatusService $job_status_service)
 {
     $job = $job_status_service->getJobStatus('pift_ci_jobs', function () {
         /** @var Database $db */
         $db = DB::getMongoDB();
         $last_job = $db->pift_ci_jobs->findOne([], ['sort' => ['updated' => -1], 'limit' => 1]);
         return $last_job->updated;
     });
     if (!empty($job->queued)) {
         return response()->json(['message' => 'The request is already queued. You should see updates soon.'])->setStatusCode(406);
     }
     $req = new PiftCiJobCollectionRequest(['sort' => 'updated', 'direction' => 'DESC']);
     $options = ['last_updated' => $job->last_updated];
     $this->dispatch(new RetrievePiftCiJobCollectionJob($req, $options));
     $job->queued = true;
     $job->save();
     return response()->json(['message' => 'We have queued the request. You should see updates soon.'])->setStatusCode(202);
 }
 public function handle(JobStatusService $job_status_service)
 {
     $job = $job_status_service->getJobStatus('pift_ci_jobs', function () {
         /** @var Database $db */
         $db = DB::getMongoDB();
         $last_job = $db->pift_ci_jobs->findOne([], ['sort' => ['updated' => -1], 'limit' => 1]);
         return $last_job->updated;
     });
     if (!empty($job->queued)) {
         $this->error('The request is already queued. You should see updates soon.');
         return 1;
     }
     $req = new PiftCiJobCollectionRequest(['sort' => 'updated', 'direction' => 'DESC']);
     $options = ['last_updated' => $job->last_updated];
     $this->dispatch(new RetrievePiftCiJobCollectionJob($req, $options));
     $job->queued = true;
     $job->save();
     $this->line('The request is now queued. You should see updates soon.');
     return 0;
 }
 public function handle(JobStatusService $job_status_service)
 {
     $type = $this->argument('type');
     $job = $job_status_service->getJobStatus('nodes-' . $type, function () use($type) {
         /** @var Database $db */
         $db = DB::getMongoDB();
         $last_job = $db->nodes->findOne([], ['sort' => ['changed' => -1], 'type' => $type, 'limit' => 1]);
         return $last_job->changed;
     });
     if (!empty($job->queued)) {
         $this->error('The request is already queued. You should see updates soon.');
         return 1;
     }
     $req = new NodeCollectionRequest(['type' => $type, 'sort' => 'changed', 'direction' => 'DESC']);
     $options = ['last_updated' => $job->last_updated, 'type' => $type];
     $this->dispatch(new RetrieveNodeCollectionJob($req, $options));
     $job->queued = true;
     $job->save();
     $this->line('The request is now queued. You should see updates soon.');
     return 0;
 }