From 7dba7c0ada1fe07999b5ea80298d49b7bb4ead76 Mon Sep 17 00:00:00 2001 From: horus Date: Tue, 24 Mar 2020 18:28:56 +0100 Subject: Fix missing updates for calendar view. --- app/Libraries/Helper.php | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'app/Libraries') diff --git a/app/Libraries/Helper.php b/app/Libraries/Helper.php index 407c58e..df6e7f3 100644 --- a/app/Libraries/Helper.php +++ b/app/Libraries/Helper.php @@ -66,6 +66,7 @@ class Helper { if ( is_null($airing) ) { echo "setCalendar: There is a bug: Anime can't be null."; + continue; } /** * Check for duplicate entry. @@ -80,23 +81,45 @@ class Helper { */ if ( ! is_null( $check ) ) { - /** - * Update watched episodes. - */ $check_watched_anime = DB::table('is_watching') ->where('mal_id', $anime->mal_id) ->where('user_id', $user->id) ->get()->first(); + + /** + * Update watched episodes in calendar view. + */ if ( $check_watched_anime->episodes_watched != $check->episodes_watched ) { echo "setCalendar: update episodes_watched from " . $check->episodes_watched . " to " . $check_watched_anime->episodes_watched . "\n"; $check->episodes_watched = $check_watched_anime->episodes_watched; $check->save(); - } else if ( $check_watched_anime->score_user != $check->score ){ - $check->score = $check_watched_anime->score_user; + } + + /** + * Update user set score in calendar view. + */ + if ( $check_watched_anime->score_user != $check->score ){ + $check->score_user = $check_watched_anime->score_user; + $check->save(); + } + + /** + * Update airing date in calendar view. + */ + if ( $airing->aired_at != $check->airing_at ) { + echo "setCalendar: Missmatch airing schedule and calendar. (" . $anime->mal_id .") Updating calendar...\n"; + $check->airing_at = $airing->aired_at; + $check->save(); + } + + /** + * Update public score in calendar view. + */ + if ( $check->score != $stats->score ) { + echo "setCalendar: Update public score. (" . $anime->mal_id .")\n"; + $check->score = $stats->score; $check->save(); - } else { - echo "setCalendar: duplicate entry. ".$anime->mal_id." continue\n"; } continue; -- cgit v1.2.3