Add more support for negated existing metatags

This commit is contained in:
Type-kun
2017-06-15 18:11:53 +05:00
parent d691c1de36
commit bf6add5273
2 changed files with 53 additions and 12 deletions

View File

@@ -322,13 +322,21 @@ class PostQueryBuilder
if q[:parent] == "none"
relation = relation.where("posts.parent_id IS NULL")
elsif q[:parent_neg] == "none" || q[:parent] == "any"
elsif q[:parent] == "any"
relation = relation.where("posts.parent_id IS NOT NULL")
elsif q[:parent]
relation = relation.where("(posts.id = ? or posts.parent_id = ?)", q[:parent].to_i, q[:parent].to_i)
has_constraints!
end
if q[:parent_neg_ids]
neg_ids = q[:parent_neg_ids].map(&:to_i)
neg_ids.delete(0)
if neg_ids.present?
relation = relation.where("posts.id not in (?) and (posts.parent_id is null or posts.parent_id not in (?))", neg_ids, neg_ids)
end
end
if q[:child] == "none"
relation = relation.where("posts.has_children = FALSE")
elsif q[:child] == "any"