Skip to content

Commit

Permalink
fix: 🐛 DMをシートに書き込む際、DBが落ちていた部分の処理が誤っていたので修正した (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikukyugamer authored Jul 4, 2022
1 parent d1d911a commit f5fb9b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions app/models/direct_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def self.missing_records
where(id_number: 1540436647376031755..1540790299618066435)
end

def self.remove_missing_records
where.not(id_number: 1540436647376031755..1540790299618066435)
end

def is_missing_record?
id_number.in?(1540436647376031755..1540790299618066435)
end
Expand Down
6 changes: 2 additions & 4 deletions app/services/sheets/write_and_update/direct_messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ def self.exec(complement_missing_messages: false)
direct_messages = if complement_missing_messages
DirectMessage.missing_records.for_spreadsheet
else
DirectMessage.for_spreadsheet
DirectMessage.remove_missing_records.for_spreadsheet
end

direct_messages.each_slice(100).with_index do |dm_100, index_on_hundred|
prepared_written_data_by_array_in_hash = []

dm_100.each_with_index do |dm, i|
next if complement_missing_messages == false && dm.is_missing_record?

dm_100.each do |dm|
inserted_hash = {}

inserted_hash['screen_name'] = dm.user.screen_name
Expand Down

0 comments on commit f5fb9b0

Please sign in to comment.