Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/middleware/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, get_response):

def __call__(self, request):
# Skip rate limiting for certain paths
exempt_paths = ['/admin/', '/static/', '/media/', '/health/']
exempt_paths = ['/admin/', '/static/', '/media/', '/health/', '/core/health/']
if any(request.path.startswith(path) for path in exempt_paths):
return self.get_response(request)

Expand Down
7 changes: 3 additions & 4 deletions core/throttling.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def throttle_failure(self):
'message': 'Too many requests. Please try again later.',
'upgrade_suggestion': {
'recommended_plan': recommended_plan,
'upgrade_url': '/plans/'
'upgrade_url': '/core/plans/'
} if recommended_plan else None
})

Expand Down Expand Up @@ -261,10 +261,9 @@ def __init__(self, user):
cache_key = throttle.get_cache_key(mock_request, None)
history = cache.get(cache_key, [])

# Filter to requests within the current window
# Filter to requests within the current window (oldest entries removed)
now = throttle.timer()
while history and history[-1] <= now - duration:
history.pop()
history = [t for t in history if t > now - duration]

used = len(history)
remaining = max(0, num_requests - used)
Expand Down