From 4f5f8604056bfaf36168b20c6b1f8d74f878ad4a Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Mon, 22 Jul 2024 15:12:54 +0200 Subject: [PATCH] fix(helpscout): rate limit respect 1 minute window --- .../maintenance/helpscout_delete_old_conversations_task.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/tasks/maintenance/helpscout_delete_old_conversations_task.rb b/app/tasks/maintenance/helpscout_delete_old_conversations_task.rb index b7256028f..a8e37a874 100644 --- a/app/tasks/maintenance/helpscout_delete_old_conversations_task.rb +++ b/app/tasks/maintenance/helpscout_delete_old_conversations_task.rb @@ -12,9 +12,9 @@ module Maintenance MODIFIED_BEFORE = 2.years.freeze - throttle_on do + throttle_on(backoff: 1.minute) do limit = Rails.cache.read(Helpscout::API::RATELIMIT_KEY) - limit.present? && limit.to_i <= 26 # check is made after each page (of 25 elements), and we need 25 calls to delete them all + limit.present? && limit.to_i <= 26 # check is made before each process but not before listing each page. External activity can affect the rate limit. end def count