fixes #2217
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
class CommentsController < ApplicationController
|
class CommentsController < ApplicationController
|
||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json
|
||||||
before_filter :member_only, :only => [:update, :create, :edit, :destroy]
|
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
|
def index
|
||||||
if params[:group_by] == "comment"
|
if params[:group_by] == "comment"
|
||||||
@@ -103,14 +103,4 @@ private
|
|||||||
raise User::PrivilegeError
|
raise User::PrivilegeError
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|||||||
@@ -101,12 +101,14 @@ class PostQueryBuilder
|
|||||||
relation
|
relation
|
||||||
end
|
end
|
||||||
|
|
||||||
def build
|
def build(relation = nil)
|
||||||
unless query_string.is_a?(Hash)
|
unless query_string.is_a?(Hash)
|
||||||
q = Tag.parse_query(query_string)
|
q = Tag.parse_query(query_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
relation = Post.where("true")
|
if relation.nil?
|
||||||
|
relation = Post.where("true")
|
||||||
|
end
|
||||||
|
|
||||||
if q[:tag_count].to_i > Danbooru.config.tag_query_limit
|
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")
|
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
|
end
|
||||||
|
|
||||||
def post_tags_match(query)
|
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
|
end
|
||||||
|
|
||||||
def search(params)
|
def search(params)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class Comment < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def post_tags_match(query)
|
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
|
end
|
||||||
|
|
||||||
def for_creator(user_id)
|
def for_creator(user_id)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Note < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def post_tags_match(query)
|
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
|
end
|
||||||
|
|
||||||
def for_creator(user_id)
|
def for_creator(user_id)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<%= select "search", "translated_present", ["yes", "no"], :include_blank => true %>
|
<%= select "search", "translated_present", ["yes", "no"], :include_blank => true %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= search_field "post_tags_match", :label => "Tags", :hint => "Meta-tags not supported" %>
|
<%= search_field "post_tags_match", :label => "Tags" %>
|
||||||
<%= submit_tag "Search" %>
|
<%= submit_tag "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<%= search_field "body_matches", :label => "Body" %>
|
<%= search_field "body_matches", :label => "Body" %>
|
||||||
<%= search_field "creator_name", :label => "User" %>
|
<%= 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" %>
|
<%= submit_tag "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<%= search_field "body_matches", :label => "Body" %>
|
<%= search_field "body_matches", :label => "Body" %>
|
||||||
<%= search_field "creator_name", :label => "Author" %>
|
<%= 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" %>
|
<%= submit_tag "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user