@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | protected function getCrawler() |
| 23 | 23 | { |
| 24 | - if(empty($this->crawler) || $this->crawler->id != $this->crawler_id) { |
|
| 24 | + if (empty($this->crawler) || $this->crawler->id != $this->crawler_id) { |
|
| 25 | 25 | $this->crawler = Crawlers::findOrFail($this->crawler_id); |
| 26 | 26 | } else { |
| 27 | 27 | $this->crawler = $this->crawler->fresh(); |
@@ -46,13 +46,13 @@ discard block |
||
| 46 | 46 | $this->getCrawler(); |
| 47 | 47 | |
| 48 | 48 | if (!$this->crawler->enabled) { |
| 49 | - throw new CrawlerException('Crawler (#' . $this->crawler_id . ') - crawler isnt enabled in database'); |
|
| 49 | + throw new CrawlerException('Crawler (#'.$this->crawler_id.') - crawler isnt enabled in database'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | $checkIfCrawlerCanBeRunned = $this->canCrawlerRunAfterPeriod(); |
| 54 | 54 | |
| 55 | - if($checkIfCrawlerCanBeRunned['status']) { |
|
| 55 | + if ($checkIfCrawlerCanBeRunned['status']) { |
|
| 56 | 56 | if (is_null($this->crawler->latest_status)) { |
| 57 | 57 | //first time it runs... |
| 58 | 58 | break; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | if ($this->crawler->latest_status == 3) { |
| 67 | - throw new CrawlerException('Crawler (#' . $this->crawler_id . ') - last run had an error'); |
|
| 67 | + throw new CrawlerException('Crawler (#'.$this->crawler_id.') - last run had an error'); |
|
| 68 | 68 | } |
| 69 | 69 | } else { |
| 70 | 70 | throw new CrawlerNotReachedTimeBetweenJobsException('Has to wait '.$checkIfCrawlerCanBeRunned['retry_in'].' more seconds to run'); |
@@ -160,13 +160,13 @@ discard block |
||
| 160 | 160 | public function canCrawlerRunAfterPeriod() { |
| 161 | 161 | $this->getCrawler(); |
| 162 | 162 | |
| 163 | - if(is_null($this->crawler->time_between)) { |
|
| 163 | + if (is_null($this->crawler->time_between)) { |
|
| 164 | 164 | return $this->canCrawlerRunAfterPeriodStatus(true); |
| 165 | 165 | } else { |
| 166 | 166 | $seconds = $this->crawler->time_between; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if(!is_null($this->crawler->last_runned_at)) { |
|
| 169 | + if (!is_null($this->crawler->last_runned_at)) { |
|
| 170 | 170 | if ($this->crawler->last_runned_at <= Carbon::now()->subSeconds($seconds)) { |
| 171 | 171 | return $this->canCrawlerRunAfterPeriodStatus(true); |
| 172 | 172 | } |
@@ -13,8 +13,8 @@ |
||
| 13 | 13 | protected $table = 'crawlers'; |
| 14 | 14 | |
| 15 | 15 | protected $fillable = [ |
| 16 | - 'name', |
|
| 17 | - 'description' |
|
| 16 | + 'name', |
|
| 17 | + 'description' |
|
| 18 | 18 | ]; |
| 19 | 19 | |
| 20 | 20 | |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | public function getLastRunnedAtAttribute() { |
| 32 | - if($this->last_run) { |
|
| 32 | + if ($this->last_run) { |
|
| 33 | 33 | return $this->last_run->created_at; |
| 34 | 34 | } |
| 35 | 35 | |