8000 :ambulance: Fixed seasons endpoint including not airing entries by pushrbx · Pull Request #482 · jikan-me/jikan-rest · GitHub
[go: up one dir, main page]

Skip to content
8000
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/Repositories/DefaultAnimeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,25 @@ public function getAiredBetween(

$finalFilter = [];

// if the premiered parameter for the filter is not null, look for those items which have a premiered attribute set,
// and equals to the parameter value, OR look for those items which doesn't have premired attribute set,
// they don't have a garbled aired string and their aired.from date is within the from-to parameters range
if ($premiered !== null) {
$finalFilter['$or'] = [
["premiered" => $premiered],
[
"premiered" => null,
"aired.string" => [
'$not' => ['$regex' => "{$from->year} to ?"]
],
...$airedFilter
]
];
} else {
$finalFilter = array_merge($finalFilter, $airedFilter);
$finalFilter["aired.string"] = [
'$not' => ['$regex' => "{$from->year} to ?"]
];
}

if (!is_null($type)) {
Expand Down
0