Преглед на файлове

Don't requests made before reset

Zed преди 2 години
родител
ревизия
d17583286a
променени са 1 файла, в които са добавени 7 реда и са изтрити 3 реда
  1. 7 3
      src/auth.nim

+ 7 - 3
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: