This commit is contained in:
Toks
2014-07-06 12:00:08 -04:00
parent 95d7b3bce5
commit 772003a55a
8 changed files with 11 additions and 19 deletions

View File

@@ -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

View File

@@ -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")

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>