Skip to content

Commit

Permalink
Use sync_since variable
Browse files Browse the repository at this point in the history
  • Loading branch information
luciajanikova committed Nov 16, 2024
1 parent 4f27ef2 commit c79c899
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/jobs/govbox/sync_folder_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def perform(folder, upvs_client: UpvsEnvironment.upvs_client, batch_size: 1000)
edesk_api = upvs_client.api(folder.box).edesk
new_messages_ids = []

sync_since = Date.parse(folder.box.settings['sync_since']) if folder.box.settings['sync_since'].present?

0.step do |k|
response_status, raw_messages = edesk_api.fetch_messages(folder.edesk_folder_id, page: k + 1, count: batch_size)

Expand All @@ -15,7 +17,7 @@ def perform(folder, upvs_client: UpvsEnvironment.upvs_client, batch_size: 1000)
moved_edesk_message_ids = []

raw_messages.each do |raw_message|
next if folder.box.settings['sync_since'].present? && (Date.parse(raw_message['delivered_at']) < Date.parse(folder.box.settings['sync_since']))
next if sync_since && (Date.parse(raw_message['delivered_at']) < sync_since)

edesk_message_id = raw_message['id']
old_folder_id = edesk_message_ids_to_folder_ids[edesk_message_id]
Expand Down

0 comments on commit c79c899

Please sign in to comment.