/post_{flags,appeals}: default to fulltext search for reason field.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user