Added uploader: support to post searching
This commit is contained in:
parent
11931075f5
commit
0cfb7b821d
4 changed files with 18 additions and 1 deletions
1
TODO
1
TODO
|
@ -11,7 +11,6 @@ everything related to posts:
|
|||
- add warning if no posts were found
|
||||
- search filters
|
||||
- safety:safe/sketchy/unsafe
|
||||
- submit:rr-
|
||||
- comment:rr-
|
||||
- comment_count: 3..5
|
||||
- fav:rr-
|
||||
|
|
|
@ -110,6 +110,11 @@ class PostDao extends AbstractDao implements ICrudDao
|
|||
return;
|
||||
}
|
||||
|
||||
elseif ($requirement->getType() === \Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_UPLOADER)
|
||||
{
|
||||
$query->innerJoin('users uploader ON uploader.id = userId');
|
||||
}
|
||||
|
||||
parent::decorateQueryFromRequirement($query, $requirement);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ class PostFilter extends BasicFilter implements IFilter
|
|||
const REQUIREMENT_TAG_COUNT = 'tagCount';
|
||||
const REQUIREMENT_FAV_COUNT = 'favCount';
|
||||
const REQUIREMENT_SCORE = 'score';
|
||||
const REQUIREMENT_UPLOADER = 'uploader.name';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
|
@ -37,6 +37,9 @@ class PostSearchParser extends AbstractSearchParser
|
|||
elseif ($token->getKey() === 'score')
|
||||
$this->addScoreRequirement($filter, $token);
|
||||
|
||||
elseif ($token->getKey() === 'uploader')
|
||||
$this->addUploaderRequirement($filter, $token);
|
||||
|
||||
else
|
||||
throw new \BadMethodCallException('Not supported');
|
||||
}
|
||||
|
@ -138,6 +141,15 @@ class PostSearchParser extends AbstractSearchParser
|
|||
self::ALLOW_COMPOSITE | self::ALLOW_RANGES);
|
||||
}
|
||||
|
||||
private function addUploaderRequirement($filter, $token)
|
||||
{
|
||||
$this->addRequirementFromToken(
|
||||
$filter,
|
||||
$token,
|
||||
\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_UPLOADER,
|
||||
self::ALLOW_COMPOSITE);
|
||||
}
|
||||
|
||||
private function dateToTime($value)
|
||||
{
|
||||
$value = strtolower(trim($value));
|
||||
|
|
Loading…
Reference in a new issue