diff --git a/public_html/templates/help.tpl b/public_html/templates/help.tpl index 72f5583e..54a2565f 100644 --- a/public_html/templates/help.tpl +++ b/public_html/templates/help.tpl @@ -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) { %> diff --git a/src/Dao/PostDao.php b/src/Dao/PostDao.php index c9a59f61..d007c8be 100644 --- a/src/Dao/PostDao.php +++ b/src/Dao/PostDao.php @@ -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); } diff --git a/src/Search/Filters/PostFilter.php b/src/Search/Filters/PostFilter.php index 0eab5b0a..1494aa34 100644 --- a/src/Search/Filters/PostFilter.php +++ b/src/Search/Filters/PostFilter.php @@ -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() { diff --git a/src/Search/ParserConfigs/PostSearchParserConfig.php b/src/Search/ParserConfigs/PostSearchParserConfig.php index b35adaa3..252bbcae 100644 --- a/src/Search/ParserConfigs/PostSearchParserConfig.php +++ b/src/Search/ParserConfigs/PostSearchParserConfig.php @@ -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()