/post_{flags,appeals}: allow searching by tags.

This commit is contained in:
evazion
2017-03-03 19:30:12 -06:00
parent f5e22ea235
commit 8d45bb6d52
4 changed files with 18 additions and 0 deletions

View File

@@ -16,6 +16,10 @@ class PostAppeal < ActiveRecord::Base
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
end
def post_tags_match(query)
PostQueryBuilder.new(query).build(self.joins(:post))
end
def resolved
joins(:post).where("posts.is_deleted = false and posts.is_flagged = false")
end
@@ -56,6 +60,10 @@ class PostAppeal < ActiveRecord::Base
q = q.where("post_id = ?", params[:post_id].to_i)
end
if params[:post_tags_match].present?
q = q.post_tags_match(params[:post_tags_match])
end
if params[:is_resolved] == "true"
q = q.resolved
elsif params[:is_resolved] == "false"

View File

@@ -24,6 +24,10 @@ class PostFlag < ActiveRecord::Base
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
end
def post_tags_match(query)
PostQueryBuilder.new(query).build(self.joins(:post))
end
def resolved
where("is_resolved = ?", true)
end
@@ -64,6 +68,10 @@ class PostFlag < ActiveRecord::Base
q = q.where("post_id = ?", params[:post_id].to_i)
end
if params[:post_tags_match].present?
q = q.post_tags_match(params[:post_tags_match])
end
if params[:is_resolved] == "true"
q = q.resolved
elsif params[:is_resolved] == "false"