/post_{flags,appeals}: default to fulltext search for reason field.

This commit is contained in:
evazion
2017-04-16 21:07:12 -05:00
parent 6d693799a0
commit 54b4a2e0c5
4 changed files with 12 additions and 6 deletions

View File

@@ -12,8 +12,11 @@ class PostAppeal < ActiveRecord::Base
module SearchMethods
def reason_matches(query)
query = "*#{query}*" unless query =~ /\*/
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
if query =~ /\*/
where("post_appeals.reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
else
where("to_tsvector('english', post_appeals.reason) @@ plainto_tsquery(?)", query.to_escaped_for_tsquery)
end
end
def post_tags_match(query)

View File

@@ -20,8 +20,11 @@ class PostFlag < ActiveRecord::Base
module SearchMethods
def reason_matches(query)
query = "*#{query}*" unless query =~ /\*/
where("reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
if query =~ /\*/
where("post_flags.reason ILIKE ? ESCAPE E'\\\\'", query.to_escaped_for_sql_like)
else
where("to_tsvector('english', post_flags.reason) @@ plainto_tsquery(?)", query.to_escaped_for_tsquery)
end
end
def post_tags_match(query)