Skip to content

Commit

Permalink
Don't requests made before reset
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Nov 1, 2023
1 parent 209f453 commit d175832
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/auth.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d175832

Please sign in to comment.