Merge pull request #10628 from colinux/helpscout-robust-api-limit

Tech: essaie de contourner les crash aléatoires sur le non respect du rate limit
This commit is contained in:
Colin Darie 2024-07-23 07:26:51 +00:00 committed by GitHub
commit 60ba6a2241
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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