diff --git a/app/controllers/delayed_jobs_controller.rb b/app/controllers/delayed_jobs_controller.rb index a8571db9c..90d6f03c3 100644 --- a/app/controllers/delayed_jobs_controller.rb +++ b/app/controllers/delayed_jobs_controller.rb @@ -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 diff --git a/app/helpers/delayed_jobs_helper.rb b/app/helpers/delayed_jobs_helper.rb new file mode 100644 index 000000000..b4edf421b --- /dev/null +++ b/app/helpers/delayed_jobs_helper.rb @@ -0,0 +1,23 @@ +module DelayedJobsHelper + def print_handler(job) + case job.name + when "Upload#process!" + 'upload post: record' + + when "Tag#update_related" + "none" + + when "TagAlias#process!" + 'alias: ' + job.payload_object.antecedent_name + " -> " + job.payload_object.consequent_name + + when "TagImplication#process!" + 'implication: ' + job.payload_object.antecedent_name + " -> " + job.payload_object.consequent_name + + when "TagAlias#clear_cache" + "none" + + else + job.handler + end + end +end diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index 49d598bed..01ec00516 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -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(" | ") + ")" diff --git a/app/models/tag.rb b/app/models/tag.rb index 6b3113f30..1a8e88145 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 67765c124..386ee0b92 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/presenters/post_set_presenters/post.rb b/app/presenters/post_set_presenters/post.rb index d4d076c67..4b64a70e4 100644 --- a/app/presenters/post_set_presenters/post.rb +++ b/app/presenters/post_set_presenters/post.rb @@ -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 diff --git a/app/views/delayed_jobs/index.html.erb b/app/views/delayed_jobs/index.html.erb index 00e0ca092..a30fc6a9c 100644 --- a/app/views/delayed_jobs/index.html.erb +++ b/app/views/delayed_jobs/index.html.erb @@ -19,7 +19,7 @@ <%= job.id %> <% if CurrentUser.is_admin? %> - <%= job.handler[:method_name] %> + <%= raw print_handler(job) %> <% end %> <%= job.attempts %> <%= job.priority %> diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index e220b5f04..45e3cd0cd 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -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