summaryrefslogtreecommitdiff
path: root/app/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'app/Libraries')
-rw-r--r--app/Libraries/Background.php19
-rw-r--r--app/Libraries/Helper.php4
2 files changed, 15 insertions, 8 deletions
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();
}