fix(helpscout): rate limit respect 1 minute window

This commit is contained in:
Colin Darie 2024-07-22 15:12:54 +02:00
parent 583bad01d2
commit 4f5f860405
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4

View file

@ -12,9 +12,9 @@ module Maintenance
MODIFIED_BEFORE = 2.years.freeze MODIFIED_BEFORE = 2.years.freeze
throttle_on do throttle_on(backoff: 1.minute) do
limit = Rails.cache.read(Helpscout::API::RATELIMIT_KEY) 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 end
def count def count