Fix #4483: Wrong order for BUR caused 12k mistags.
Bug: if a BUR contained a mass update followed by an alias, then the alias would become active before the mass update, which could cause the mass update to return incorrect results if both the alias and mass update touched the same tags. This happened because all aliases and implications in the BUR were set to a queued state before the mass update was processed, but putting an alias in the queued state effectively made it active. The fix is to remove the queued state. This was only used anyway as a debugging tool anyway to monitor the state of BURs as they were being processed.
This commit is contained in:
@@ -193,7 +193,7 @@ class Artist < ApplicationRecord
|
||||
# potential race condition but unlikely
|
||||
unless TagImplication.where(:antecedent_name => name, :consequent_name => "banned_artist").exists?
|
||||
tag_implication = TagImplication.create!(antecedent_name: name, consequent_name: "banned_artist", skip_secondary_validations: true, creator: banner)
|
||||
tag_implication.approve!(approver: banner)
|
||||
tag_implication.approve!(banner)
|
||||
end
|
||||
|
||||
update!(is_banned: true)
|
||||
|
||||
@@ -3,15 +3,10 @@ class TagAlias < TagRelationship
|
||||
validates_uniqueness_of :antecedent_name, scope: :status, conditions: -> { active }
|
||||
validate :absence_of_transitive_relation
|
||||
|
||||
module ApprovalMethods
|
||||
def approve!(approver: CurrentUser.user)
|
||||
update(approver: approver, status: "queued")
|
||||
ProcessTagAliasJob.perform_later(self)
|
||||
end
|
||||
def approve!(approver)
|
||||
ProcessTagAliasJob.perform_later(self, approver)
|
||||
end
|
||||
|
||||
include ApprovalMethods
|
||||
|
||||
def self.to_aliased(names)
|
||||
names = Array(names).map(&:to_s)
|
||||
return [] if names.empty?
|
||||
@@ -19,10 +14,10 @@ class TagAlias < TagRelationship
|
||||
names.map { |name| aliases[name] || name }
|
||||
end
|
||||
|
||||
def process!(user: User.system)
|
||||
update!(status: "processing")
|
||||
def process!(approver)
|
||||
update!(approver: approver, status: "processing")
|
||||
move_aliases_and_implications
|
||||
TagMover.new(antecedent_name, consequent_name, user: user).move!
|
||||
TagMover.new(antecedent_name, consequent_name, user: User.system).move!
|
||||
update!(status: "active")
|
||||
rescue Exception => e
|
||||
update!(status: "error: #{e}")
|
||||
|
||||
@@ -120,13 +120,13 @@ class TagImplication < TagRelationship
|
||||
end
|
||||
|
||||
module ApprovalMethods
|
||||
def process!
|
||||
def process!(approver)
|
||||
unless valid?
|
||||
raise errors.full_messages.join("; ")
|
||||
end
|
||||
|
||||
CurrentUser.scoped(User.system) do
|
||||
update(status: "processing")
|
||||
update(approver: approver, status: "processing")
|
||||
update_posts
|
||||
update(status: "active")
|
||||
end
|
||||
@@ -135,9 +135,8 @@ class TagImplication < TagRelationship
|
||||
DanbooruLogger.log(e, tag_implication_id: id, antecedent_name: antecedent_name, consequent_name: consequent_name)
|
||||
end
|
||||
|
||||
def approve!(approver: CurrentUser.user)
|
||||
update(approver: approver, status: "queued")
|
||||
ProcessTagImplicationJob.perform_later(self)
|
||||
def approve!(approver)
|
||||
ProcessTagImplicationJob.perform_later(self, approver)
|
||||
end
|
||||
|
||||
def create_mod_action
|
||||
|
||||
@@ -16,7 +16,7 @@ class TagRelationship < ApplicationRecord
|
||||
belongs_to :consequent_wiki, class_name: "WikiPage", foreign_key: "consequent_name", primary_key: "title", optional: true
|
||||
|
||||
scope :active, -> {approved}
|
||||
scope :approved, -> {where(status: %w[active processing queued])}
|
||||
scope :approved, -> {where(status: %w[active processing])}
|
||||
scope :deleted, -> {where(status: "deleted")}
|
||||
scope :expired, -> {where("created_at < ?", EXPIRY.days.ago)}
|
||||
scope :old, -> {where("created_at >= ? and created_at < ?", EXPIRY.days.ago, EXPIRY_WARNING.days.ago)}
|
||||
@@ -24,7 +24,7 @@ class TagRelationship < ApplicationRecord
|
||||
scope :retired, -> {where(status: "retired")}
|
||||
|
||||
before_validation :normalize_names
|
||||
validates_format_of :status, :with => /\A(active|deleted|pending|processing|queued|retired|error: .*)\Z/
|
||||
validates_format_of :status, :with => /\A(active|deleted|pending|processing|retired|error: .*)\Z/
|
||||
validates_presence_of :antecedent_name, :consequent_name
|
||||
validates :approver, presence: { message: "must exist" }, if: -> { approver_id.present? }
|
||||
validates :forum_topic, presence: { message: "must exist" }, if: -> { forum_topic_id.present? }
|
||||
@@ -36,7 +36,7 @@ class TagRelationship < ApplicationRecord
|
||||
end
|
||||
|
||||
def is_approved?
|
||||
status.in?(%w[active processing queued])
|
||||
status.in?(%w[active processing])
|
||||
end
|
||||
|
||||
def is_rejected?
|
||||
@@ -76,7 +76,7 @@ class TagRelationship < ApplicationRecord
|
||||
status = status.downcase
|
||||
|
||||
if status == "approved"
|
||||
where(status: %w[active processing queued])
|
||||
where(status: %w[active processing])
|
||||
else
|
||||
where(status: status)
|
||||
end
|
||||
@@ -89,7 +89,7 @@ class TagRelationship < ApplicationRecord
|
||||
|
||||
def pending_first
|
||||
# unknown statuses return null and are sorted first
|
||||
order(Arel.sql("array_position(array['queued', 'processing', 'pending', 'active', 'deleted', 'retired'], status::text) NULLS FIRST, id DESC"))
|
||||
order(Arel.sql("array_position(array['processing', 'pending', 'active', 'deleted', 'retired'], status::text) NULLS FIRST, id DESC"))
|
||||
end
|
||||
|
||||
def search(params)
|
||||
|
||||
Reference in New Issue
Block a user