Added special:tumbleweed

This commit is contained in:
rr- 2015-12-29 12:23:22 +01:00
parent 770dba8a41
commit 965f772515
4 changed files with 23 additions and 0 deletions

View file

@ -130,6 +130,7 @@
{search: 'special:liked', description: 'posts liked by currently logged in user'}, {search: 'special:liked', description: 'posts liked by currently logged in user'},
{search: 'special:disliked', description: 'posts disliked 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: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) { %> _.each(table, function(row) { %>
<tr> <tr>

View file

@ -194,6 +194,17 @@ class PostDao extends AbstractDao implements ICrudDao
return; 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); parent::decorateQueryFromRequirement($query, $requirement);
} }

View file

@ -34,6 +34,7 @@ class PostFilter extends BasicFilter implements IFilter
const REQUIREMENT_COMMENT_AUTHOR = 'commentedBy.name'; const REQUIREMENT_COMMENT_AUTHOR = 'commentedBy.name';
const REQUIREMENT_TYPE = 'posts.contentType'; const REQUIREMENT_TYPE = 'posts.contentType';
const REQUIREMENT_USER_SCORE = 'posts.userScore'; const REQUIREMENT_USER_SCORE = 'posts.userScore';
const REQUIREMENT_TUMBLEWEED = 'tumbleweed';
public function __construct() public function __construct()
{ {

View file

@ -165,6 +165,16 @@ class PostSearchParserConfig extends AbstractSearchParserConfig
$token->setValue($this->authService->getLoggedInUser()->getName()); $token->setValue($this->authService->getLoggedInUser()->getName());
return $this->getRequirementForNamedToken($token); 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() public function createFilter()