fixes #2550
This commit is contained in:
@@ -82,6 +82,9 @@ class TagAlias < ActiveRecord::Base
|
||||
raise errors.full_messages.join("; ")
|
||||
end
|
||||
|
||||
tries = 0
|
||||
|
||||
begin
|
||||
admin = CurrentUser.user || User.admins.first
|
||||
CurrentUser.scoped(admin, "127.0.0.1") do
|
||||
update_column(:status, "processing")
|
||||
@@ -94,9 +97,17 @@ class TagAlias < ActiveRecord::Base
|
||||
update_column(:status, "active")
|
||||
end
|
||||
rescue Exception => e
|
||||
if tries < 5
|
||||
tries += 1
|
||||
sleep 2 ** tries
|
||||
retry
|
||||
end
|
||||
|
||||
update_forum_topic_for_error(e)
|
||||
update_column(:status, "error: #{e}")
|
||||
NewRelic::Agent.notice_error(e, :custom_params => {:tag_alias_id => id, :antecedent_name => antecedent_name, :consequent_name => consequent_name})
|
||||
end
|
||||
end
|
||||
|
||||
def is_pending?
|
||||
status == "pending"
|
||||
@@ -246,6 +257,14 @@ class TagAlias < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def update_forum_topic_for_error(e)
|
||||
if forum_topic
|
||||
forum_topic.posts.create(
|
||||
:body => "The tag alias #{antecedent_name} -> #{consequent_name} failed during processing. Reason: #{e}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def update_forum_topic_for_reject
|
||||
if forum_topic
|
||||
forum_topic.posts.create(
|
||||
|
||||
@@ -125,6 +125,9 @@ class TagImplication < ActiveRecord::Base
|
||||
raise errors.full_messages.join("; ")
|
||||
end
|
||||
|
||||
tries = 0
|
||||
|
||||
begin
|
||||
admin = CurrentUser.user || User.admins.first
|
||||
CurrentUser.scoped(admin, "127.0.0.1") do
|
||||
update_column(:status, "processing")
|
||||
@@ -134,9 +137,17 @@ class TagImplication < ActiveRecord::Base
|
||||
update_forum_topic_for_approve if update_topic
|
||||
end
|
||||
rescue Exception => e
|
||||
if tries < 5
|
||||
tries += 1
|
||||
sleep 2 ** tries
|
||||
retry
|
||||
end
|
||||
|
||||
update_forum_topic_for_error(e)
|
||||
update_column(:status, "error: #{e}")
|
||||
NewRelic::Agent.notice_error(e, :custom_params => {:tag_implication_id => id, :antecedent_name => antecedent_name, :consequent_name => consequent_name})
|
||||
end
|
||||
end
|
||||
|
||||
def absence_of_circular_relation
|
||||
# We don't want a -> b && b -> a chains
|
||||
@@ -237,6 +248,14 @@ class TagImplication < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def update_forum_topic_for_error(e)
|
||||
if forum_topic
|
||||
forum_topic.posts.create(
|
||||
:body => "The tag implication #{antecedent_name} -> #{consequent_name} failed during processing. Reason: #{e}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def reject!
|
||||
update_forum_topic_for_reject
|
||||
destroy
|
||||
|
||||
Reference in New Issue
Block a user