Skip to content

Commit

Permalink
chore: update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
samhotep committed Dec 20, 2024
1 parent ce42bb8 commit 22811dd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions webapp/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def rate_limited(*args, **kwargs):
try:
# Get the initial request
initial_request = json.loads(flask.session[func.__name__])
# Get the current limit
# Get the seconds limit for these attempts
seconds_limit = rate_limit_attempt_map.get(request_limit)
for limit in sorted(rate_limit_attempt_map.keys()):
seconds_limit = rate_limit_attempt_map.get(limit)
Expand All @@ -72,13 +72,13 @@ def rate_limited(*args, **kwargs):
# Abort if the time is too early for this number of attempts
# Or if the max number of attempts has been exceeded
if initial_request["attempts"] >= request_limit:
# Reset the timer if we have exceeded the limit
if (
time_since_last_request.total_seconds()
< seconds_limit.total_seconds()
):
return flask.abort(429)
else:
# Reset the timer if we have exceeded the limit
initial_request["timestamp"] = datetime.now()

# Otherwise update the session
Expand Down

0 comments on commit 22811dd

Please sign in to comment.