Added special:tumbleweed
This commit is contained in:
parent
770dba8a41
commit
965f772515
4 changed files with 23 additions and 0 deletions
|
@ -130,6 +130,7 @@
|
|||
{search: 'special:liked', description: 'posts liked by currently logged in user'},
|
||||
{search: 'special:disliked', description: 'posts disliked by currently logged in user'},
|
||||
{search: 'special:fav', description: 'posts added to favorites by currently logged in user'},
|
||||
{search: 'special:tumbleweed', description: 'posts with score of 0, without comments and without favorites'},
|
||||
];
|
||||
_.each(table, function(row) { %>
|
||||
<tr>
|
||||
|
|
|
@ -194,6 +194,17 @@ class PostDao extends AbstractDao implements ICrudDao
|
|||
return;
|
||||
}
|
||||
|
||||
elseif ($requirement->getType() === PostFilter::REQUIREMENT_TUMBLEWEED)
|
||||
{
|
||||
$sql = 'posts.score = 0
|
||||
AND posts.commentCount = 0
|
||||
AND posts.favCount = 0';
|
||||
if ($requirement->isNegated())
|
||||
$sql = 'NOT (' . $sql . ')';
|
||||
$query->where($sql, true);
|
||||
return;
|
||||
}
|
||||
|
||||
parent::decorateQueryFromRequirement($query, $requirement);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ class PostFilter extends BasicFilter implements IFilter
|
|||
const REQUIREMENT_COMMENT_AUTHOR = 'commentedBy.name';
|
||||
const REQUIREMENT_TYPE = 'posts.contentType';
|
||||
const REQUIREMENT_USER_SCORE = 'posts.userScore';
|
||||
const REQUIREMENT_TUMBLEWEED = 'tumbleweed';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
|
@ -165,6 +165,16 @@ class PostSearchParserConfig extends AbstractSearchParserConfig
|
|||
$token->setValue($this->authService->getLoggedInUser()->getName());
|
||||
return $this->getRequirementForNamedToken($token);
|
||||
});
|
||||
|
||||
$this->defineSpecialTokenParser(
|
||||
['tumbleweed'],
|
||||
function (SearchToken $token)
|
||||
{
|
||||
$requirement = new Requirement();
|
||||
$requirement->setType(PostFilter::REQUIREMENT_TUMBLEWEED);
|
||||
$requirement->setNegated($token->isNegated());
|
||||
return $requirement;
|
||||
});
|
||||
}
|
||||
|
||||
public function createFilter()
|
||||
|
|
Loading…
Reference in a new issue