From 22a4f471e59a4b2d0f6616b62b0d414ff3577df5 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 25 Jun 2024 16:45:41 +0200 Subject: [PATCH] fix(helpscout): rate limit take into deletions into account --- .../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 cbe388fb1..6cd65260a 100644 --- a/app/tasks/maintenance/helpscout_delete_old_conversations_task.rb +++ b/app/tasks/maintenance/helpscout_delete_old_conversations_task.rb @@ -14,7 +14,7 @@ module Maintenance throttle_on do limit = Rails.cache.read(Helpscout::API::RATELIMIT_KEY) - limit.present? && limit == 0 + limit.present? && limit <= 26 # check is made after each page (of 25 elements), and we need 25 calls to delete them all end def count @@ -35,7 +35,7 @@ module Maintenance # "number" is the current page (always 1 in our case) # iterate until there are no remaining pages - break if pagination[:totalPages] == pagination[:number] + break if pagination[:totalPages] == 0 || pagination[:totalPages] == pagination[:number] end end end