diff options
| author | horus | 2020-03-10 01:39:27 +0100 |
|---|---|---|
| committer | horus | 2020-03-10 01:39:27 +0100 |
| commit | 0679190dfe45007ce3eb53ac139b344e0d724540 (patch) | |
| tree | 8ed09bb9820062b940f157c9405072f5deae2cd6 /app | |
| parent | 75e57c66dd49c55acb29d31693ddd022032b54fb (diff) | |
| download | senpai-0679190dfe45007ce3eb53ac139b344e0d724540.tar.gz | |
Nasty bug fix.
Diffstat (limited to 'app')
| -rw-r--r-- | app/Console/Kernel.php | 13 | ||||
| -rw-r--r-- | app/Libraries/Background.php | 19 | ||||
| -rw-r--r-- | app/Libraries/Helper.php | 4 |
3 files changed, 25 insertions, 11 deletions
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 4e125a3..a1cac43 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -34,23 +34,30 @@ class Kernel extends ConsoleKernel $schedule->call( function(){ $background = new Background(); $background->saveAnimeStats(); - })->dailyAt('23:00'); + })->dailyAt('22:00'); $schedule->call( function(){ $background = new Background(); + echo "SaveSeason(): \n"; $background->saveSeason(); sleep(10); + echo "\ncheckIfIsAiring(): \n"; $background->checkIfIsAiring(); sleep(10); + echo "\nsaveAiringForAll(): \n"; $background->saveAiringForAll(); - })->dailyAt('19:00'); + })->dailyAt('18:00'); + #})->everyMinute(); $schedule->call( function(){ $helper = new Helper(); #$helper->createUser( 'll-' ); + echo "setIsWatchingForAll(): \n"; $helper->setIsWatchingForAll(); + echo "\nsetCalendarForAll(): \n"; $helper->setCalendarForAll(); - })->dailyAt('18:30'); + })->dailyAt('19:30'); + #})->everyMinute(); } /** diff --git a/app/Libraries/Background.php b/app/Libraries/Background.php index 626cc6f..1c271f1 100644 --- a/app/Libraries/Background.php +++ b/app/Libraries/Background.php @@ -20,7 +20,7 @@ class Background { public function saveAiring(Anime $anime) { if ( ! $anime->is_airing ) { - echo "Anime (" . $anime->mal_id . ") is not airing. Skipping.\n"; + echo "saveAiring: Anime (" . $anime->mal_id . ") is not airing. Skipping.\n"; return; } @@ -41,11 +41,11 @@ class Background { try { $airing_data = $anime->getDataFromAnilist(); } catch( \Exception $e ) { - echo "Getting Data from Anilist failed for anime: " . $anime->title_pref . " (" . $anime->mal_id . ")\n"; + echo "saveAiring: Getting Data from Anilist failed for anime: " . $anime->title_pref . " (" . $anime->mal_id . ")\n"; return; } if ( "" == $airing_data ) { - echo "Got empty data from Anilist for anime: " . $anime->title_pref . " (" . $anime->mal_id . ")\n"; + echo "saveAiring: Got empty data from Anilist for anime: " . $anime->title_pref . " (" . $anime->mal_id . ")\n"; return; } @@ -55,16 +55,19 @@ class Background { if ( ! is_null( $airing->episode ) ) { if ( ! is_null( $airing_data->nextAiringEpisode ) && ( $airing->episode == $airing_data->nextAiringEpisode->episode) ) { - if ( $airing->aired_at == $airing_data->nextAiringEpisode->airingAt ) { + if ( $airing->aired_at == Carbon::createFromTimestamp($airing_data->nextAiringEpisode->airingAt) ) { /** * Double entry. */ + echo "saveAiring: Double entry: (" . $anime->mal_id . ") Episode: " . $airing->episode . "\n"; return; } else { /** * We need to delete/reinsert because the airing date was postponed. * Keep in mind that it's still the same episode which should be aired. */ + echo "saveAiring: The airing was postponed: " . $anime->title_pref . " (" . $anime->mal_id . ")\n"; + echo "saveAiring: Original: " . $airing->episode . "/" . $airing->aired_at . " New: " . Carbon::createFromTimestamp($airing_data->nextAiringEpisode->airingAt) ."\n"; DB::table('airing') ->where('mal_id', $anime->mal_id) ->where('episode', $airing->episode) @@ -86,12 +89,12 @@ class Background { } if ( is_null($airing_data->duration) ) { - echo "No duration found for anime: " . $anime->title_pref . " (" . $anime->mal_id . "). (Autoset to 20.)\n"; + echo "saveAiring: No duration found for anime: " . $anime->title_pref . " (" . $anime->mal_id . "). (Autoset to 20.)\n"; $airing->duration = 20; } if ( is_null($airing->aired_at) ) { - echo "No airing date found for anime: " . $anime->title_pref . " (" . $anime->mal_id . ")\n"; + echo "saveAiring: No airing date found for anime: " . $anime->title_pref . " (" . $anime->mal_id . ")\n"; return; } @@ -123,7 +126,7 @@ class Background { /** * We already have this anime saved. */ - echo "Duplicate entry: (" . $entry->getMalID() . ") Continue\n"; + echo "saveSeason: Duplicate entry: (" . $entry->getMalID() . ") Continue\n"; continue; } @@ -163,7 +166,7 @@ class Background { (new \Jikan\Request\Anime\AnimeRequest( $anime->mal_id )) ); } catch (\Exception $e) { - echo "Problem requesting AnimeInfo for (" . $anime->mal_id . ") continue\n"; + echo "checkIfIsAiring: Problem requesting AnimeInfo for (" . $anime->mal_id . ") continue\n"; echo $e->getMessage(); echo "\n\n"; } diff --git a/app/Libraries/Helper.php b/app/Libraries/Helper.php index 65d774b..7d89b2c 100644 --- a/app/Libraries/Helper.php +++ b/app/Libraries/Helper.php @@ -64,6 +64,9 @@ class Helper { $stats = $anime->getStats()->get()->first(); $airing = $anime->getAiring()->get()->first(); + if ( is_null($airing) ) { + echo "setCalendar: There is a bug: Anime can't be null."; + } /** * Check for duplicate entry. */ @@ -123,6 +126,7 @@ class Helper { * Check for anime which aren't watched anymore and delete them. */ $not_watched = DB::table('is_watching') + ->where('user_id', $user->id) ->whereNotIn('mal_id', $actually_watching) ->delete(); } |
