summaryrefslogtreecommitdiff
path: root/app/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'app/Libraries')
-rw-r--r--app/Libraries/Background.php15
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;