should solve all residual tag_query_limit bugs
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
class DelayedJobsController < ApplicationController
|
class DelayedJobsController < ApplicationController
|
||||||
def index
|
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
|
||||||
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 + "''"
|
"''" + escaped_token + "''"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def tag_query_limit
|
||||||
|
Danbooru.config.tag_query_limit
|
||||||
|
end
|
||||||
|
|
||||||
def add_tag_string_search_relation(tags, relation)
|
def add_tag_string_search_relation(tags, relation)
|
||||||
tag_query_sql = []
|
tag_query_sql = []
|
||||||
|
|
||||||
if tags[:include].any?
|
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(" | ") + ")"
|
tag_query_sql << "(" + escape_string_for_tsquery(tags[:include]).join(" | ") + ")"
|
||||||
has_constraints!
|
has_constraints!
|
||||||
end
|
end
|
||||||
|
|
||||||
if tags[:related].any?
|
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(" & ") + ")"
|
tag_query_sql << "(" + escape_string_for_tsquery(tags[:related]).join(" & ") + ")"
|
||||||
has_constraints!
|
has_constraints!
|
||||||
end
|
end
|
||||||
|
|
||||||
if tags[:exclude].any?
|
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?
|
raise ::Post::SearchError.new("You cannot search for only excluded tags") unless has_constraints?
|
||||||
|
|
||||||
tag_query_sql << "!(" + escape_string_for_tsquery(tags[:exclude]).join(" | ") + ")"
|
tag_query_sql << "!(" + escape_string_for_tsquery(tags[:exclude]).join(" | ") + ")"
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ class Tag < ActiveRecord::Base
|
|||||||
output[:include] << tag[1..-1]
|
output[:include] << tag[1..-1]
|
||||||
|
|
||||||
elsif tag =~ /\*/
|
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?
|
matches = ["~no_matches~"] if matches.empty?
|
||||||
output[:include] += matches
|
output[:include] += matches
|
||||||
|
|
||||||
|
|||||||
@@ -416,9 +416,9 @@ class User < ActiveRecord::Base
|
|||||||
|
|
||||||
def tag_query_limit
|
def tag_query_limit
|
||||||
if is_privileged?
|
if is_privileged?
|
||||||
Danbooru.config.tag_query_limit
|
Danbooru.config.base_tag_query_limit
|
||||||
elsif is_platinum?
|
elsif is_platinum?
|
||||||
Danbooru.config.tag_query_limit * 2
|
Danbooru.config.base_tag_query_limit * 2
|
||||||
else
|
else
|
||||||
2
|
2
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ module PostSetPresenters
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pattern_tags
|
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
|
end
|
||||||
|
|
||||||
def related_tags_for_group
|
def related_tags_for_group
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= job.id %></td>
|
<td><%= job.id %></td>
|
||||||
<% if CurrentUser.is_admin? %>
|
<% if CurrentUser.is_admin? %>
|
||||||
<td><%= job.handler[:method_name] %></td>
|
<td><%= raw print_handler(job) %></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td><%= job.attempts %></td>
|
<td><%= job.attempts %></td>
|
||||||
<td><%= job.priority %></td>
|
<td><%= job.priority %></td>
|
||||||
|
|||||||
@@ -118,10 +118,18 @@ module Danbooru
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Users cannot search for more than X regular tags at a time.
|
# Users cannot search for more than X regular tags at a time.
|
||||||
def tag_query_limit
|
def base_tag_query_limit
|
||||||
6
|
6
|
||||||
end
|
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
|
# Max number of posts to cache
|
||||||
def tag_subscription_post_limit
|
def tag_subscription_post_limit
|
||||||
200
|
200
|
||||||
|
|||||||
Reference in New Issue
Block a user