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:
evazion
2020-12-01 16:01:30 -06:00
parent 8717c319ab
commit 4741a52cc4
7 changed files with 2 additions and 15 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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)