From e6194704303c4e5ad44c1bb9d6c2e17fe5eb133b Mon Sep 17 00:00:00 2001 From: horus Date: Fri, 25 Sep 2020 16:46:19 +0200 Subject: bugfix --- app/Libraries/Background.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'app') 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; -- cgit v1.2.3