diff options
| author | horus | 2020-03-24 18:28:56 +0100 |
|---|---|---|
| committer | horus | 2020-03-24 18:28:56 +0100 |
| commit | 7dba7c0ada1fe07999b5ea80298d49b7bb4ead76 (patch) | |
| tree | fc272b97993b69724fea5ebb6fa0b5e1a2bd5038 /app | |
| parent | 9c36acdbde287c4fddec76153536ab5b342cd0a8 (diff) | |
| download | senpai-7dba7c0ada1fe07999b5ea80298d49b7bb4ead76.tar.gz | |
Fix missing updates for calendar view.
Diffstat (limited to 'app')
| -rw-r--r-- | app/Libraries/Helper.php | 37 |
1 files changed, 30 insertions, 7 deletions
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; |
