diff options
| author | horus | 2020-09-25 16:46:19 +0200 |
|---|---|---|
| committer | horus | 2020-09-25 16:46:19 +0200 |
| commit | e6194704303c4e5ad44c1bb9d6c2e17fe5eb133b (patch) | |
| tree | 48bb92b7fccbd9d553fec3873d2973ae655f7bc4 /app | |
| parent | 6725134c9f316c05e306e2496fa55c8a9a46f9ee (diff) | |
| download | senpai-e6194704303c4e5ad44c1bb9d6c2e17fe5eb133b.tar.gz | |
bugfix
Diffstat (limited to 'app')
| -rw-r--r-- | app/Libraries/Background.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/app/Libraries/Background.php b/app/Libraries/Background.php index 2bfe8a5..afd92b3 100644 --- a/app/Libraries/Background.php +++ b/app/Libraries/Background.php @@ -138,6 +138,9 @@ class Background { $anime = Anime::get(); } + $counter = 0; + $failure = 0; + foreach($anime as $entry ) { # skip if we have crawled stats from today if ( ! empty($entry->getStats()->get()->last()) ) { @@ -147,21 +150,20 @@ class Background { } } - $stats_counter = 0; $animeStats = new AnimeStats(); - $failure = 0; if ( $animeStats->fill($entry->mal_id) ) { + # Only save if no error $animeStats->save(); + $counter++; - $stats_counter++; } else { $failure++; } if ( 3 < $failure ) { - echo "Got " . $failure . " failures. Returning...\n"; + echo "Got " . $failure . " failures and " . $counter . " entries. Returning...\n"; return; } @@ -169,7 +171,7 @@ class Background { sleep(5); } - echo "Got stats for " . $stats_counter . " anime.\n"; + echo "Got stats for " . $counter . " anime.\n"; } public function checkIfIsAiring() { @@ -372,7 +374,8 @@ class Background { ->where('mal_id', $fill->mal_id) ->update(['image_url' => $fill->image_url]); } - sleep(1); + + sleep(5); } echo $count; |
