コード例 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $resource = $this->argument('resource');
     $action = $this->option('action');
     $startPage = (int) $this->option('startPage');
     $perPage = (int) $this->option('perPage');
     try {
         $harvest = Harvest::where('resource', $resource)->where('action', $action)->firstOrFail();
     } catch (\Exception $e) {
         $this->info('There is no existing action for updating ' . ucwords($action) . ' ' . ucwords($resource) . '.');
         exit('Nothing was updated.');
     }
     $options = ['startPage' => $startPage, 'perPage' => $perPage, 'lastRun' => new Carbon('2001-01-01')];
     $job = new UpdateResourceJob($harvest, $options);
     $message = 'Fully refreshing ' . $action . ' ' . $resource . ' ' . $perPage . ' at a time';
     if (isset($lastRun)) {
         $message .= ' with entries updated since ' . $lastRun->format('r');
     }
     $this->info($message);
     $this->dispatch($job);
 }
コード例 #2
0
 /**
  * @return \Illuminate\View\View
  */
 public function performersPopularity()
 {
     try {
         $harvest = Harvest::where('resource', 'performers')->where('action', 'popularity')->firstOrFail();
     } catch (\Exception $e) {
         abort(404, 'There is no existing action for updating Performers Popularity.');
     }
     /**
      * Get all the categories and then loop through them creating an
      * UpdatePerformerPopularityJob for each one.
      */
     try {
         $categories = Category::active()->orderBy('id')->get();
     } catch (\Exception $e) {
         abort(404, 'There are no categories yet. Please ensure you have run the Active Categories job.');
     }
     // Get the last category->id so we can later detect that the Job for that
     // category->id has completed in order to know to fire the ResourceUpdateWasCompleted Event
     $last_category_id = $categories->last()->id;
     foreach ($categories as $category) {
         $job = new UpdatePerformerPopularityJob($harvest, $category->id, $last_category_id);
         $this->dispatch($job);
     }
     return view('resource', ['pageTitle' => 'Performers | Popularity | TEvo Harvester', 'job' => $job]);
 }
コード例 #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 protected function handlePopularity()
 {
     $resource = 'performers';
     $action = 'popularity';
     try {
         $harvest = Harvest::where('resource', $resource)->where('action', $action)->firstOrFail();
     } catch (\Exception $e) {
         $this->info('There is no existing action for updating ' . ucwords($action) . ' ' . ucwords($resource) . '.');
         exit('Nothing was updated.');
     }
     /**
      * Get all the categories and then loop through them creating an
      * UpdatePerformerPopularityJob for each one.
      */
     try {
         $categories = Category::active()->orderBy('id')->get();
     } catch (\Exception $e) {
         abort(404, 'There are no categories yet. Please ensure you have run the Active Categories job.');
     }
     $message = 'Updating the popularity_score for the 100 most popular Performers in each Category.';
     $this->info($message);
     // Get the last category_id so we can later detect that the Job for that
     // category_id has completed in order to know to fire the ResourceUpdateWasCompleted Event
     $last_category_id = $categories->last()->id;
     foreach ($categories as $category) {
         $job = new UpdatePerformerPopularityJob($harvest, $category->id, $last_category_id);
         $this->dispatch($job);
     }
 }
コード例 #4
0
 /**
  * Handle the event.
  *
  * @param  ResourceUpdateWasCompleted $event
  *
  * @return void
  */
 public function handle(ResourceUpdateWasCompleted $event)
 {
     $status = Harvest::where('resource', '=', $event->harvest->resource)->where('action', '=', $event->harvest->action)->firstOrFail();
     $status->last_run_at = $event->startTime;
     $status->save();
 }