aliases/implications: remove 'error' state.
Remove the error status from aliases and implications. Aliases and implications normally shouldn't fail because they're validated beforehand. If they do, just let the delayed job itself record the failure. Also disable the delayed job from retrying if the alias/implication somehow fails.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
class ProcessTagRelationshipJob < ApplicationJob
|
||||
queue_as :bulk_update
|
||||
retry_on Exception, attempts: 0
|
||||
|
||||
def perform(class_name:, approver:, antecedent_name:, consequent_name:, forum_topic: nil)
|
||||
relation_class = Kernel.const_get(class_name)
|
||||
|
||||
@@ -98,8 +98,6 @@ class DText
|
||||
"The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] has been rejected."
|
||||
elsif obj.is_pending?
|
||||
"The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] is pending approval."
|
||||
elsif obj.is_errored?
|
||||
"The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] (#{relationship} failed during processing."
|
||||
else # should never happen
|
||||
"The #{obj.relationship} ##{obj.id} [[#{obj.antecedent_name}]] -> [[#{obj.consequent_name}]] has an unknown status."
|
||||
end
|
||||
|
||||
@@ -12,9 +12,6 @@ class TagAlias < TagRelationship
|
||||
|
||||
def process!
|
||||
TagMover.new(antecedent_name, consequent_name, user: User.system).move!
|
||||
rescue Exception => e
|
||||
update!(status: "error: #{e}")
|
||||
DanbooruLogger.log(e, tag_alias_id: id, antecedent_name: antecedent_name, consequent_name: consequent_name)
|
||||
end
|
||||
|
||||
def absence_of_transitive_relation
|
||||
|
||||
@@ -113,9 +113,6 @@ class TagImplication < TagRelationship
|
||||
CurrentUser.scoped(User.system) do
|
||||
update_posts
|
||||
end
|
||||
rescue Exception => e
|
||||
update(status: "error: #{e}")
|
||||
DanbooruLogger.log(e, tag_implication_id: id, antecedent_name: antecedent_name, consequent_name: consequent_name)
|
||||
end
|
||||
|
||||
def create_mod_action
|
||||
|
||||
@@ -20,7 +20,7 @@ class TagRelationship < ApplicationRecord
|
||||
scope :retired, -> {where(status: "retired")}
|
||||
|
||||
before_validation :normalize_names
|
||||
validates_format_of :status, :with => /\A(active|deleted|retired|error: .*)\Z/
|
||||
validates :status, inclusion: { in: %w[active deleted retired] }
|
||||
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? }
|
||||
@@ -47,10 +47,6 @@ class TagRelationship < ApplicationRecord
|
||||
status == "active"
|
||||
end
|
||||
|
||||
def is_errored?
|
||||
status =~ /\Aerror:/
|
||||
end
|
||||
|
||||
def reject!
|
||||
update!(status: "deleted")
|
||||
end
|
||||
|
||||
@@ -26,7 +26,6 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
|
||||
should allow_value('active').for(:status)
|
||||
should allow_value('deleted').for(:status)
|
||||
should allow_value('error: derp').for(:status)
|
||||
|
||||
should_not allow_value('ACTIVE').for(:status)
|
||||
should_not allow_value('error').for(:status)
|
||||
|
||||
@@ -22,7 +22,6 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
|
||||
should allow_value('active').for(:status)
|
||||
should allow_value('deleted').for(:status)
|
||||
should allow_value('error: derp').for(:status)
|
||||
|
||||
should_not allow_value('ACTIVE').for(:status)
|
||||
should_not allow_value('error').for(:status)
|
||||
|
||||
Reference in New Issue
Block a user