/** * */ 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; }