Use `update_all` to prevent `after_commit` from executing again.
This commit is contained in:
parent
605e60b016
commit
99e2bab62d
|
@ -98,14 +98,14 @@ module Jobs
|
||||||
title.gsub!(/ +/, ' ')
|
title.gsub!(/ +/, ' ')
|
||||||
title.strip!
|
title.strip!
|
||||||
if title.present?
|
if title.present?
|
||||||
crawled = topic_link.update_attributes(title: title[0..255], crawled_at: Time.now)
|
crawled = (TopicLink.where(id: topic_link.id).update_all(['title = ?, crawled_at = CURRENT_TIMESTAMP', title[0..255]]) == 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue Exception
|
rescue Exception
|
||||||
# If there was a connection error, do nothing
|
# If there was a connection error, do nothing
|
||||||
ensure
|
ensure
|
||||||
topic_link.update_column(:crawled_at, Time.now) if !crawled && topic_link.present?
|
TopicLink.where(id: topic_link.id).update_all('crawled_at = CURRENT_TIMESTAMP') if !crawled && topic_link.present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue