Skip to content

Commit

Permalink
Followup improvement for issue#1394 - Reindex elastic search not poss…
Browse files Browse the repository at this point in the history
…ible because of <null>/Twitter::NullObject.
  • Loading branch information
martini committed Sep 8, 2017
1 parent 4094bd1 commit b96c572
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class FixedTwitterTicketArticlePreferences4 < ActiveRecord::Migration
class FixedTwitterTicketArticlePreferences4 < ActiveRecord::Migration[5.0]
def up

# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')

# find article preferences with Twitter::NullObject and replace it with nill to prevent elasticsearch index issue
article_type = Ticket::Article::Type.find_by(name: ['twitter status', 'twitter direct-message'])
article_ids = Ticket::Article.where(type_id: article_type.id).pluck(:id)
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 = Ticket::Article.find(article_id)
next if !article.preferences
Expand Down

0 comments on commit b96c572

Please sign in to comment.