Skip to content
Merged
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
21 changes: 11 additions & 10 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def clean(value, strip=True):

@app.get("/api/evaluate")
async def evaluate_models(
k: int = 10,
k: int = Query(10, ge=1, le=100),
mode: str = "all",
alpha: float = 0.4,
beta: float = 0.35,
Expand Down Expand Up @@ -467,14 +467,14 @@ def _apply_rate_limit(
reset_time = max(0, reset_time)

_prune_rate_limit_buckets(now)
global _request_counter
_request_counter += 1
if _request_counter >= CLEANUP_THRESHOLD:
_request_counter = 0
# Garbage Collection: Remove empty buckets to prevent memory leak
empty_keys = [k for k, v in _rate_limit_buckets.items() if not v]
for k in empty_keys:
del _rate_limit_buckets[k]
global _request_counter
_request_counter += 1
if _request_counter >= CLEANUP_THRESHOLD:
_request_counter = 0
# Garbage Collection: Remove empty buckets to prevent memory leak
empty_keys = [k for k, v in _rate_limit_buckets.items() if not v]
for k in empty_keys:
del _rate_limit_buckets[k]

response.headers["x-ratelimit-limit"] = str(rate_limit)
response.headers["x-ratelimit-remaining"] = str(remaining)
Expand Down Expand Up @@ -2070,7 +2070,8 @@ def get_recommendations(
user_id: Optional[str] = Query(None),
target_catalog: Optional[str] = Query(None),
model_version: Optional[str] = Query(None),
strategy: Optional[str] = Query(None),
strategy: Optional[str] = Query(None),
method: Optional[str] = Query(None, description="knn for KNN-based collaborative filtering"),
):
rate_limited = _apply_rate_limit(
request,
Expand Down
Loading