private function estimate_time($type) { // clear history $history = $this->client->getHistory(); $history->clear(); unset($history); // $remaining_records = 0; if (empty($this->start_time)) { $this->start_time = time(); } if (empty($this->expected_records)) { $this->expected_records = MsProfile::count(); } switch ($type) { case 'counties': $total_counties = MsCounty::count(); $counties_crawled = MsCounty::where('status', '!=', '0')->count(); $remaining_records = $total_counties - $counties_crawled; break; case 'profiles': $this->records_crawled = MsProfile::where('status', '=', '1')->count(); $this->state->records_crawled = $this->records_crawled; if ($this->records_crawled) { $remaining_records = $this->expected_records - $this->records_crawled; } break; } $record_time = time() - $this->start_time; $expected_time = round($record_time * $remaining_records); $this->state->expected_time = Carbon::now()->addSeconds($expected_time); $this->state->save(); // Check Crawl State $this->check_state(); }