Example #1
0
 /**
  * 
  */
 public function addJob($job, $data, $delay = null)
 {
     $payload = $this->createPayload($job, $data);
     $job = new Job();
     $job->status = Job::STATUS_OPEN;
     $job->available_at = empty($delay) ? \Carbon\Carbon::now() : $delay;
     $job->payload = $payload;
     $job->save();
     return $job->id;
 }
Example #2
0
 /**
  * 
  */
 protected function getStats()
 {
     $jobs = Job::select(\Illuminate\Support\Facades\DB::raw('count(*) as jobs_count, status'))->groupBy('status')->get();
     $o = "";
     foreach ($jobs as $j) {
         switch ($j->status) {
             case Job::STATUS_OPEN:
                 $o .= 'Open - ';
                 break;
             case Job::STATUS_WAITING:
                 $o .= 'Waiting - ';
                 break;
             case Job::STATUS_STARTED:
                 $o .= 'Started - ';
                 break;
             case Job::STATUS_FINISHED:
                 $o .= 'Done - ';
                 break;
             case Job::STATUS_FAILED:
                 $o .= 'Failed - ';
                 break;
         }
         $o .= $j->jobs_count . " \n";
     }
     return $o;
 }
 protected function getQdbJob()
 {
     $this->activeJob = \Veer\Services\Queuedb\Job::where('status', '<=', '1')->where('available_at', '<=', date('Y-m-d H:i:00', time()))->orderBy('available_at', 'asc')->first();
     return $this->activeJob;
 }
Example #4
0
 /**
  * Show Jobs
  */
 public function getQdbJobs()
 {
     $items = \Veer\Services\Queuedb\Job::all();
     $items = $items->sortBy('available_at');
     $items_failed = \DB::table("failed_jobs")->get();
     $statuses = array(\Veer\Services\Queuedb\Job::STATUS_OPEN => "Open", \Veer\Services\Queuedb\Job::STATUS_WAITING => "Waiting", \Veer\Services\Queuedb\Job::STATUS_STARTED => "Started", \Veer\Services\Queuedb\Job::STATUS_FINISHED => "Finished", \Veer\Services\Queuedb\Job::STATUS_FAILED => "Failed");
     return array('jobs' => $items, 'failed' => $items_failed, 'statuses' => $statuses, 'availModules' => $this->getAvailModules('queues'));
 }
Example #5
0
 public function unpauseJob()
 {
     \Veer\Services\Queuedb\Job::where('id', '=', head(array_keys($this->actionUnpause)))->update(['status' => \Veer\Services\Queuedb\Job::STATUS_OPEN]);
     $this->actionUnpause = null;
 }