fixes #2217
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
class CommentsController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
before_filter :member_only, :only => [:update, :create, :edit, :destroy]
|
||||
rescue_from ActiveRecord::StatementInvalid, :with => :search_error
|
||||
rescue_from ActiveRecord::StatementInvalid, :with => :rescue_exception
|
||||
|
||||
def index
|
||||
if params[:group_by] == "comment"
|
||||
@@ -103,14 +103,4 @@ private
|
||||
raise User::PrivilegeError
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def search_error(e)
|
||||
if e.message =~ /syntax error in tsquery/
|
||||
@error_message = "Meta-tags are not supported in comment searches by tag"
|
||||
render :template => "static/error", :status => 500
|
||||
else
|
||||
rescue_exception(e)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -101,12 +101,14 @@ class PostQueryBuilder
|
||||
relation
|
||||
end
|
||||
|
||||
def build
|
||||
def build(relation = nil)
|
||||
unless query_string.is_a?(Hash)
|
||||
q = Tag.parse_query(query_string)
|
||||
end
|
||||
|
||||
relation = Post.where("true")
|
||||
if relation.nil?
|
||||
relation = Post.where("true")
|
||||
end
|
||||
|
||||
if q[:tag_count].to_i > Danbooru.config.tag_query_limit
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{Danbooru.config.tag_query_limit} tags at a time")
|
||||
|
||||
@@ -13,7 +13,7 @@ class ArtistCommentary < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def post_tags_match(query)
|
||||
joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query.to_escaped_for_tsquery_split)
|
||||
PostQueryBuilder.new(query).build(self.joins(:post))
|
||||
end
|
||||
|
||||
def search(params)
|
||||
|
||||
@@ -33,7 +33,7 @@ class Comment < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def post_tags_match(query)
|
||||
joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', ?)", query.to_escaped_for_tsquery_split)
|
||||
PostQueryBuilder.new(query).build(self.joins(:post))
|
||||
end
|
||||
|
||||
def for_creator(user_id)
|
||||
|
||||
@@ -29,7 +29,7 @@ class Note < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def post_tags_match(query)
|
||||
joins(:post).where("posts.tag_index @@ to_tsquery('danbooru', E?)", query.to_escaped_for_tsquery_split)
|
||||
PostQueryBuilder.new(query).build(self.joins(:post))
|
||||
end
|
||||
|
||||
def for_creator(user_id)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<%= select "search", "translated_present", ["yes", "no"], :include_blank => true %>
|
||||
</div>
|
||||
|
||||
<%= search_field "post_tags_match", :label => "Tags", :hint => "Meta-tags not supported" %>
|
||||
<%= search_field "post_tags_match", :label => "Tags" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<%= search_field "body_matches", :label => "Body" %>
|
||||
<%= search_field "creator_name", :label => "User" %>
|
||||
<%= search_field "post_tags_match", :label => "Tags", :hint => "Meta-tags not supported" %>
|
||||
<%= search_field "post_tags_match", :label => "Tags" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<%= search_field "body_matches", :label => "Body" %>
|
||||
<%= search_field "creator_name", :label => "Author" %>
|
||||
<%= search_field "post_tags_match", :label => "Tags", :hint => "Meta-tags not supported" %>
|
||||
<%= search_field "post_tags_match", :label => "Tags" %>
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user