Added fav_count: support to post searching
This commit is contained in:
parent
a80050b70e
commit
47081293ef
3 changed files with 12 additions and 1 deletions
1
TODO
1
TODO
|
@ -15,7 +15,6 @@ everything related to posts:
|
|||
- comment:rr-
|
||||
- comment_count: 3..5
|
||||
- fav:rr-
|
||||
- fav_count:3..5
|
||||
- score:3..5
|
||||
- file_size:3K..5M
|
||||
- image_size:huge/large/medium/small
|
||||
|
|
|
@ -15,6 +15,7 @@ class PostFilter extends BasicFilter implements IFilter
|
|||
const REQUIREMENT_DATE = 'uploadTime';
|
||||
const REQUIREMENT_HASH = 'name';
|
||||
const REQUIREMENT_TAG_COUNT = 'tagCount';
|
||||
const REQUIREMENT_FAV_COUNT = 'favCount';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
|
@ -31,6 +31,9 @@ class PostSearchParser extends AbstractSearchParser
|
|||
elseif ($token->getKey() === 'tag_count')
|
||||
$this->addTagCountRequirement($filter, $token);
|
||||
|
||||
elseif ($token->getKey() === 'fav_count')
|
||||
$this->addFavCountRequirement($filter, $token);
|
||||
|
||||
else
|
||||
throw new \BadMethodCallException('Not supported');
|
||||
}
|
||||
|
@ -111,6 +114,14 @@ class PostSearchParser extends AbstractSearchParser
|
|||
$filter->addRequirement($requirement);
|
||||
}
|
||||
|
||||
private function addFavCountRequirement($filter, $token)
|
||||
{
|
||||
$requirement = new \Szurubooru\SearchServices\Requirements\Requirement();
|
||||
$requirement->setType(\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_FAV_COUNT);
|
||||
$requirement->setValue($this->createRequirementValue($token->getValue(), self::ALLOW_COMPOSITE | self::ALLOW_RANGES));
|
||||
$filter->addRequirement($requirement);
|
||||
}
|
||||
|
||||
private function dateToTime($value)
|
||||
{
|
||||
$value = strtolower(trim($value));
|
||||
|
|
Loading…
Reference in a new issue