diff --git a/app/jobs/govbox/sync_folder_job.rb b/app/jobs/govbox/sync_folder_job.rb index e1844cc0..cb3aa472 100644 --- a/app/jobs/govbox/sync_folder_job.rb +++ b/app/jobs/govbox/sync_folder_job.rb @@ -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) @@ -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]