fixes #2550
This commit is contained in:
@@ -82,20 +82,31 @@ class TagAlias < ActiveRecord::Base
|
|||||||
raise errors.full_messages.join("; ")
|
raise errors.full_messages.join("; ")
|
||||||
end
|
end
|
||||||
|
|
||||||
admin = CurrentUser.user || User.admins.first
|
tries = 0
|
||||||
CurrentUser.scoped(admin, "127.0.0.1") do
|
|
||||||
update_column(:status, "processing")
|
begin
|
||||||
move_aliases_and_implications
|
admin = CurrentUser.user || User.admins.first
|
||||||
clear_all_cache
|
CurrentUser.scoped(admin, "127.0.0.1") do
|
||||||
ensure_category_consistency
|
update_column(:status, "processing")
|
||||||
update_posts
|
move_aliases_and_implications
|
||||||
update_forum_topic_for_approve if update_topic
|
clear_all_cache
|
||||||
update_column(:post_count, consequent_tag.post_count)
|
ensure_category_consistency
|
||||||
update_column(:status, "active")
|
update_posts
|
||||||
|
update_forum_topic_for_approve if update_topic
|
||||||
|
update_column(:post_count, consequent_tag.post_count)
|
||||||
|
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
|
||||||
rescue Exception => 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?
|
def is_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,17 +125,28 @@ class TagImplication < ActiveRecord::Base
|
|||||||
raise errors.full_messages.join("; ")
|
raise errors.full_messages.join("; ")
|
||||||
end
|
end
|
||||||
|
|
||||||
admin = CurrentUser.user || User.admins.first
|
tries = 0
|
||||||
CurrentUser.scoped(admin, "127.0.0.1") do
|
|
||||||
update_column(:status, "processing")
|
begin
|
||||||
update_posts
|
admin = CurrentUser.user || User.admins.first
|
||||||
update_column(:status, "active")
|
CurrentUser.scoped(admin, "127.0.0.1") do
|
||||||
update_descendant_names_for_parents
|
update_column(:status, "processing")
|
||||||
update_forum_topic_for_approve if update_topic
|
update_posts
|
||||||
|
update_column(:status, "active")
|
||||||
|
update_descendant_names_for_parents
|
||||||
|
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
|
||||||
rescue Exception => 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
|
def absence_of_circular_relation
|
||||||
@@ -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