From d17583286a11586c6ff5cffc43bc997e525a578e Mon Sep 17 00:00:00 2001 From: Zed Date: Wed, 1 Nov 2023 05:44:08 +0000 Subject: [PATCH] Don't requests made before reset --- src/auth.nim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/auth.nim b/src/auth.nim index 8c901e2..fed7df3 100644 --- a/src/auth.nim +++ b/src/auth.nim @@ -64,12 +64,16 @@ proc getAccountPoolHealth*(): JsonNode = apiStatus = account.apis[api] reqs = apiMaxReqs[api] - apiStatus.remaining - reqsPerApi.mgetOrPut($api, 0).inc reqs - totalReqs.inc reqs - if apiStatus.limited: limited.incl account.id + # no requests made with this account and endpoint since the limit reset + if apiStatus.reset < now: + continue + + reqsPerApi.mgetOrPut($api, 0).inc reqs + totalReqs.inc reqs + if accountPool.len > 0: average = average div accountPool.len else: