diff options
| author | horus | 2020-09-23 17:33:02 +0200 |
|---|---|---|
| committer | horus | 2020-09-23 17:33:02 +0200 |
| commit | 6725134c9f316c05e306e2496fa55c8a9a46f9ee (patch) | |
| tree | db486eb26f0e04b5982e69a687d9b8bf7affda14 | |
| parent | 92c77557fcb3f50138d878a62e83d36997424d9e (diff) | |
| download | senpai-6725134c9f316c05e306e2496fa55c8a9a46f9ee.tar.gz | |
fake statistics if we detect a gap in our data
| -rw-r--r-- | app/Http/Controllers/AnimeController.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/Http/Controllers/AnimeController.php b/app/Http/Controllers/AnimeController.php index 1da62e1..73c8842 100644 --- a/app/Http/Controllers/AnimeController.php +++ b/app/Http/Controllers/AnimeController.php @@ -34,7 +34,7 @@ class AnimeController extends Controller { $anime["stats"] = $anime->getStats()->orderBy('created_at', 'asc')->get(); - foreach( $anime["stats"] as $stats ) { + foreach( $anime["stats"] as $index => $stats ) { if ( ! is_null($stats->score) ) { $score[] = $stats->score; $rank[] = $stats->rank; @@ -44,6 +44,14 @@ class AnimeController extends Controller { $popularity[] = $stats->popularity; $members[] = $stats->members; $favorites[] = $stats->favorites; + + /** + * Sometimes we have a gap in our data, so we fake it by making it the same like last day. + */ + if ( 0 == $stats->plan_to_watch && 0 != $index && 0 != $anime["stats"][$index-1]->plan_to_watch ) { + $stats = $anime["stats"][$index-1]; + } + $watching[] = $stats->watching; $completed[] = $stats->completed; $onhold[] = $stats->onhold; |
