|
@@ -7,13 +7,13 @@ class FixedTwitterTicketArticlePreferences4 < ActiveRecord::Migration[5.0]
|
|
|
# find article preferences with Twitter::NullObject and replace it with nill to prevent elasticsearch index issue
|
|
|
article_type_ids = Ticket::Article::Type.where(name: ['twitter status', 'twitter direct-message']).pluck(:id)
|
|
|
article_ids = Ticket::Article.where(type_id: article_type_ids).pluck(:id)
|
|
|
- article_ids.each { |article_id|
|
|
|
+ article_ids.each do |article_id|
|
|
|
article = Ticket::Article.find(article_id)
|
|
|
next if !article.preferences
|
|
|
changed = false
|
|
|
- article.preferences.each { |_key, value|
|
|
|
+ article.preferences.each do |_key, value|
|
|
|
next if value.class != ActiveSupport::HashWithIndifferentAccess
|
|
|
- value.each { |sub_key, sub_level|
|
|
|
+ value.each do |sub_key, sub_level|
|
|
|
if sub_level.class == NilClass
|
|
|
value[sub_key] = nil
|
|
|
next
|
|
@@ -26,11 +26,11 @@ class FixedTwitterTicketArticlePreferences4 < ActiveRecord::Migration[5.0]
|
|
|
next if sub_level.class != Twitter::NullObject
|
|
|
value[sub_key] = nil
|
|
|
changed = true
|
|
|
- }
|
|
|
- }
|
|
|
+ end
|
|
|
+ end
|
|
|
next if !changed
|
|
|
article.save!
|
|
|
- }
|
|
|
+ end
|
|
|
|
|
|
end
|
|
|
end
|