Exemple #1
0
 private function loadJobs($result)
 {
     $jobs = [];
     foreach ($result as $document) {
         $jobs[] = $this->jobTransformer->toPresenter($document, new Job());
     }
     return $jobs;
 }
Exemple #2
0
 private function indexJobs()
 {
     $this->total = DB::table('phpjob_jobs')->count();
     $this->processed = 0;
     $this->write('info', '=== [JOBS] ===');
     Job::chunk($this->batch, function ($jobs) {
         $offset = $this->processed;
         $this->processed += count($jobs);
         $documents = [];
         foreach ($jobs as $job) {
             $document = $this->elastica->createDocument([], 'jobs', 'activehire', $job->jobid);
             $document = $this->jobTransformer->toDocument($job, $document);
             $documents[] = $document;
         }
         $this->elastica->addDocuments($documents);
         $this->write('info', 'Indexed jobs from ' . $offset . ' to ' . $this->processed . ' (' . floor($this->processed / $this->total * 100) . '%).');
     });
     $this->write('info', '=== [/JOBS] ===');
 }