Fixed scoremin and scoremax

This commit is contained in:
Marcin Kurczewski 2014-11-17 23:04:23 +01:00
parent 6a751ed0b2
commit 2996f27671

View file

@ -43,13 +43,17 @@ class PostSearchParser extends AbstractSearchParser
$tokenKey = $token->getKey(); $tokenKey = $token->getKey();
$tokenValue = $token->getValue(); $tokenValue = $token->getValue();
if ($this->matches($tokenKey, ['tag_min', 'tag_max', 'fav_min', 'fav_max', 'score_min', 'score_max'])) $countAliases = ['tag_count' => 'tag', 'fav_count' => 'fav', 'score' => 'score'];
foreach ($countAliases as $realKey => $baseAlias)
{
if ($this->matches($tokenKey, [$baseAlias . '_min', $baseAlias . '_max']))
{ {
$token = new NamedSearchToken(); $token = new NamedSearchToken();
$token->setKey(str_replace('__', '_', str_replace(['min', 'max'], '_count', $tokenKey))); $token->setKey($realKey);
$token->setValue(strpos($tokenKey, 'min') !== false ? $tokenValue . '..' : '..' . $tokenValue); $token->setValue(strpos($tokenKey, 'min') !== false ? $tokenValue . '..' : '..' . $tokenValue);
return $this->decorateFilterFromNamedToken($filter, $token); return $this->decorateFilterFromNamedToken($filter, $token);
} }
}
$map = $map =
[ [