should solve all residual tag_query_limit bugs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class DelayedJobsController < ApplicationController
|
||||
def index
|
||||
@delayed_jobs = Delayed::Job.where("handler not like ? and handler not like ?", "%method_name: :update_related%", "%method_name: :process!%").order("created_at desc").paginate(params[:page])
|
||||
@delayed_jobs = Delayed::Job.order("created_at desc").paginate(params[:page])
|
||||
end
|
||||
end
|
||||
|
||||
23
app/helpers/delayed_jobs_helper.rb
Normal file
23
app/helpers/delayed_jobs_helper.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
module DelayedJobsHelper
|
||||
def print_handler(job)
|
||||
case job.name
|
||||
when "Upload#process!"
|
||||
'<strong>upload post</strong>: <a href="/uploads/' + job.payload_object.object.id.to_s + '">record</a>'
|
||||
|
||||
when "Tag#update_related"
|
||||
"none"
|
||||
|
||||
when "TagAlias#process!"
|
||||
'<strong>alias</strong>: ' + job.payload_object.antecedent_name + " -> " + job.payload_object.consequent_name
|
||||
|
||||
when "TagImplication#process!"
|
||||
'<strong>implication</strong>: ' + job.payload_object.antecedent_name + " -> " + job.payload_object.consequent_name
|
||||
|
||||
when "TagAlias#clear_cache"
|
||||
"none"
|
||||
|
||||
else
|
||||
job.handler
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -49,24 +49,28 @@ class PostQueryBuilder
|
||||
"''" + escaped_token + "''"
|
||||
end
|
||||
end
|
||||
|
||||
def tag_query_limit
|
||||
Danbooru.config.tag_query_limit
|
||||
end
|
||||
|
||||
def add_tag_string_search_relation(tags, relation)
|
||||
tag_query_sql = []
|
||||
|
||||
if tags[:include].any?
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{CurrentUser.user.tag_query_limit} tags at a time") if tags[:include].size > CurrentUser.user.tag_query_limit
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{tag_query_limit} tags at a time") if tags[:include].size > tag_query_limit
|
||||
tag_query_sql << "(" + escape_string_for_tsquery(tags[:include]).join(" | ") + ")"
|
||||
has_constraints!
|
||||
end
|
||||
|
||||
if tags[:related].any?
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{CurrentUser.user.tag_query_limit} tags at a time") if tags[:related].size > CurrentUser.user.tag_query_limit
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{tag_query_limit} tags at a time") if tags[:related].size > tag_query_limit
|
||||
tag_query_sql << "(" + escape_string_for_tsquery(tags[:related]).join(" & ") + ")"
|
||||
has_constraints!
|
||||
end
|
||||
|
||||
if tags[:exclude].any?
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{CurrentUser.user.tag_query_limit} tags at a time") if tags[:exclude].size > CurrentUser.user.tag_query_limit
|
||||
raise ::Post::SearchError.new("You cannot search for more than #{tag_query_limit} tags at a time") if tags[:exclude].size > tag_query_limit
|
||||
raise ::Post::SearchError.new("You cannot search for only excluded tags") unless has_constraints?
|
||||
|
||||
tag_query_sql << "!(" + escape_string_for_tsquery(tags[:exclude]).join(" | ") + ")"
|
||||
|
||||
@@ -210,7 +210,7 @@ class Tag < ActiveRecord::Base
|
||||
output[:include] << tag[1..-1]
|
||||
|
||||
elsif tag =~ /\*/
|
||||
matches = Tag.name_matches(tag).all(:select => "name", :limit => CurrentUser.user.tag_query_limit, :order => "post_count DESC").map(&:name)
|
||||
matches = Tag.name_matches(tag).all(:select => "name", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC").map(&:name)
|
||||
matches = ["~no_matches~"] if matches.empty?
|
||||
output[:include] += matches
|
||||
|
||||
|
||||
@@ -416,9 +416,9 @@ class User < ActiveRecord::Base
|
||||
|
||||
def tag_query_limit
|
||||
if is_privileged?
|
||||
Danbooru.config.tag_query_limit
|
||||
Danbooru.config.base_tag_query_limit
|
||||
elsif is_platinum?
|
||||
Danbooru.config.tag_query_limit * 2
|
||||
Danbooru.config.base_tag_query_limit * 2
|
||||
else
|
||||
2
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ module PostSetPresenters
|
||||
end
|
||||
|
||||
def pattern_tags
|
||||
Tag.name_matches(post_set.tag_string).all(:select => "name", :limit => CurrentUser.user.tag_query_limit, :order => "post_count DESC").map(&:name)
|
||||
Tag.name_matches(post_set.tag_string).all(:select => "name", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC").map(&:name)
|
||||
end
|
||||
|
||||
def related_tags_for_group
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<tr>
|
||||
<td><%= job.id %></td>
|
||||
<% if CurrentUser.is_admin? %>
|
||||
<td><%= job.handler[:method_name] %></td>
|
||||
<td><%= raw print_handler(job) %></td>
|
||||
<% end %>
|
||||
<td><%= job.attempts %></td>
|
||||
<td><%= job.priority %></td>
|
||||
|
||||
@@ -118,10 +118,18 @@ module Danbooru
|
||||
end
|
||||
|
||||
# Users cannot search for more than X regular tags at a time.
|
||||
def tag_query_limit
|
||||
def base_tag_query_limit
|
||||
6
|
||||
end
|
||||
|
||||
def tag_query_limit
|
||||
if CurrentUser.user.present?
|
||||
CurrentUser.user.tag_query_limit
|
||||
else
|
||||
base_tag_query_limit * 2
|
||||
end
|
||||
end
|
||||
|
||||
# Max number of posts to cache
|
||||
def tag_subscription_post_limit
|
||||
200
|
||||
|
||||
Reference in New Issue
Block a user