/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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<%= simple_form_for(:search, url: post_appeals_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||
<%= f.input :reason_matches, label: "Reason", input_html: { value: params[:search][:reason_matches] } %>
|
||||
<%= f.input :reason_matches, label: "Reason", hint: "Use * for wildcard searches", input_html: { value: params[:search][:reason_matches] } %>
|
||||
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match] } %>
|
||||
<%= f.input :post_id, label: "Post ID", input_html: { value: params[:search][:post_id] } %>
|
||||
<%= f.input :creator_name, label: "Creator", input_html: { value: params[:search][:creator_name] } %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<%= simple_form_for(:search, url: post_flags_path, method: :get, defaults: { required: false }, html: { class: "inline-form" }) do |f| %>
|
||||
<%= f.input :reason_matches, label: "Reason", input_html: { value: params[:search][:reason_matches] } %>
|
||||
<%= f.input :reason_matches, label: "Reason", hint: "Use * for wildcard searches", input_html: { value: params[:search][:reason_matches] } %>
|
||||
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match] } %>
|
||||
<%= f.input :post_id, label: "Post ID", input_html: { value: params[:search][:post_id] } %>
|
||||
<% if CurrentUser.is_moderator? %>
|
||||
|
||||
Reference in New Issue
Block a user