Skip to content

Commit

Permalink
user list bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
irfan-dahir committed Sep 18, 2021
1 parent 5d64985 commit b941842
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
1 change: 0 additions & 1 deletion app/Providers/SearchQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Jikan\Request\Search\AnimeSearchRequest;
use Jikan\Request\Search\MangaSearchRequest;
use Jikan\Request\Search\PersonSearchRequest;
use \voku\helper\AntiXSS;
use Jikan\Helper\Constants as JikanConstants;

class SearchQueryBuilder
Expand Down
40 changes: 19 additions & 21 deletions app/Providers/UserListQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static function create(Request $request, $parser)
}

// animelist only queries
if ($request instanceof UserAnimeListRequest) {
if ($parser instanceof UserAnimeListRequest) {

// order by
if ($orderBy !== null && array_key_exists($orderBy, self::VALID_ANIME_ORDER_BY)) {
Expand All @@ -141,27 +141,25 @@ public static function create(Request $request, $parser)
}

// aired from
if ($airedFrom !== null) {
if (preg_match("~[0-9]{4}-[0-9]{2}-[0-9]{2}~", $airedFrom)) {
$airedFrom = explode("-", $airedFrom);

$parser->setAiredFrom(
(int) $airedFrom[2],
(int) $airedFrom[1],
(int) $airedFrom[0]
);
}
if ($airedFrom !== null && preg_match("~[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}~", $airedFrom)) {
$airedFrom = explode("-", $airedFrom);

$parser->setAiredFrom(
(int) $airedFrom[0],
(int) $airedFrom[1],
(int) $airedFrom[2]
);
}

// aired to
if ($airedTo !== null) {
if (preg_match("~[0-9]{4}-[0-9]{2}-[0-9]{2}~", $airedTo)) {
if (preg_match("~[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}~", $airedTo)) {
$airedTo = explode("-", $airedTo);

$parser->setAiredTo(
(int) $airedTo[2],
(int) $airedTo[0],
(int) $airedTo[1],
(int) $airedTo[0]
(int) $airedTo[2]
);
}
}
Expand Down Expand Up @@ -190,7 +188,7 @@ public static function create(Request $request, $parser)

}

if ($request instanceof UserMangaListRequest) {
if ($parser instanceof UserMangaListRequest) {
// order by
if ($orderBy !== null && array_key_exists($orderBy, self::VALID_MANGA_ORDER_BY)) {
$orderBy = self::VALID_MANGA_ORDER_BY[$orderBy];
Expand All @@ -207,26 +205,26 @@ public static function create(Request $request, $parser)

// published from
if ($publishedFrom !== null) {
if (preg_match("~[0-9]{4}-[0-9]{2}-[0-9]{2}~", $publishedFrom)) {
if (preg_match("~[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}~", $publishedFrom)) {
$publishedFrom = explode("-", $publishedFrom);

$parser->setPublishedFrom(
(int) $publishedFrom[2],
(int) $publishedFrom[0],
(int) $publishedFrom[1],
(int) $publishedFrom[0]
(int) $publishedFrom[2]
);
}
}

// published to
if ($publishedTo !== null) {
if (preg_match("~[0-9]{4}-[0-9]{2}-[0-9]{2}~", $publishedTo)) {
if (preg_match("~[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}~", $publishedTo)) {
$publishedTo = explode("-", $publishedTo);

$parser->setPublishedTo(
(int) $publishedTo[2],
(int) $publishedTo[0],
(int) $publishedTo[1],
(int) $publishedTo[0]
(int) $publishedTo[2]
);
}
}
Expand Down

0 comments on commit b941842

Please sign in to comment.