From b3c5212c845eaccf499767d943738c8350ad98ac Mon Sep 17 00:00:00 2001 From: rr- Date: Tue, 24 Nov 2015 21:56:27 +0100 Subject: [PATCH] Added ability to search tags by usage count --- src/Search/Filters/TagFilter.php | 1 + src/Search/Parsers/TagSearchParser.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/Search/Filters/TagFilter.php b/src/Search/Filters/TagFilter.php index 4fee563a..698293aa 100644 --- a/src/Search/Filters/TagFilter.php +++ b/src/Search/Filters/TagFilter.php @@ -13,6 +13,7 @@ class TagFilter extends BasicFilter implements IFilter const REQUIREMENT_CREATION_TIME = 'creationTime'; const REQUIREMENT_LAST_EDIT_TIME = 'lastEditTime'; const REQUIREMENT_CATEGORY = 'category'; + const REQUIREMENT_USAGE_COUNT = 'usages'; public function __construct() { diff --git a/src/Search/Parsers/TagSearchParser.php b/src/Search/Parsers/TagSearchParser.php index 3e77c204..7163ad60 100644 --- a/src/Search/Parsers/TagSearchParser.php +++ b/src/Search/Parsers/TagSearchParser.php @@ -40,6 +40,16 @@ class TagSearchParser extends AbstractSearchParser return; } + if ($this->matches($token->getKey(), ['usage_count', 'usages', 'usage'])) + { + $this->addRequirementFromToken( + $filter, + $token, + TagFilter::REQUIREMENT_USAGE_COUNT, + self::ALLOW_RANGES | self::ALLOW_COMPOSITE); + return; + } + if ($this->matches($token->getKey(), ['category'])) { $this->addRequirementFromToken(