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