コード例 #1
0
 /**
  *
  */
 private function completed()
 {
     echo $this->state->state_name . ": Crawl Completed : " . Carbon::now()->toDateTimeString() . PHP_EOL;
     $this->state->status = "Post Crawl Job";
     $this->state->save();
     $this->create_packages();
     $completed_at = Carbon::now();
     $crawl_time = $completed_at->diffInSeconds($this->state->started_at);
     if ($this->records_crawled) {
         $record_time = round($crawl_time / $this->records_crawled);
     } else {
         $record_time = 0;
     }
     $this->state->completed_at = $completed_at;
     $this->state->crawl_state = 'stopped';
     $this->state->save();
     $stats = new SexoffendersStat();
     $stats->sexoffender_id = $this->state->id;
     $stats->started_at = $this->state->started_at;
     $stats->completed_at = $completed_at;
     $stats->records_crawled = $this->records_crawled;
     $stats->crawl_time = gmdate("H:i:s", (int) $crawl_time);
     $stats->record_time = gmdate("H:i:s", (int) $record_time);
     $stats->save();
     $this->reset_crawl();
     return;
 }
コード例 #2
0
 public function data_completed(Request $request)
 {
     $sexoffenders = SexoffendersStat::join('sexoffenders', 'sexoffenders_stats.sexoffender_id', '=', 'sexoffenders.id')->select(array('sexoffenders_stats.id', 'sexoffenders.state_name', 'sexoffenders.state_code', 'sexoffenders.state_url', 'sexoffenders_stats.started_at', 'sexoffenders_stats.completed_at', 'sexoffenders_stats.records_crawled'));
     $start = $request->get('start');
     return Datatables::of($sexoffenders)->addColumn('actions', function ($state) {
         $date_completed = $state->completed_at->format('d-m-Y');
         $file = strtolower($state->state_code) . '-' . $date_completed;
         return '<a href="http://rt.midatha.com.s3-website-us-west-2.amazonaws.com/sexoffenders/' . $file . '.zip" class="btn btn-xs btn-danger dt-delete"><i class="fa  fa-download"></i> Download</a>';
     })->editColumn('id', function () use(&$start) {
         $start++;
         return $start;
     })->editColumn('state_name', '<a href="http://www.nullrefer.com/?{{$state_url}}" target="_blank">{{$state_name}}</a>')->make(true);
 }