add support for searching for dup-related flags

This commit is contained in:
r888888888
2017-04-21 13:50:44 -07:00
parent 24154af54b
commit d9ea925f4e
6 changed files with 21 additions and 4 deletions

View File

@@ -33,6 +33,14 @@ class PostFlag < ActiveRecord::Base
end
end
def duplicate
where("to_tsvector('english', post_flags.reason) @@ to_tsquery('dup | duplicate | sample | smaller')")
end
def not_duplicate
where("to_tsvector('english', post_flags.reason) @@ to_tsquery('!dup & !duplicate & !sample & !smaller')")
end
def post_tags_match(query)
PostQueryBuilder.new(query).build(self.joins(:post))
end
@@ -98,6 +106,8 @@ class PostFlag < ActiveRecord::Base
q = q.where("reason LIKE ?", Reasons::REJECTED)
when "deleted"
q = q.where("reason = ? OR reason LIKE ?", Reasons::UNAPPROVED, Reasons::REJECTED)
when "duplicate"
q = q.duplicate
end
q