Public Access
fix(recipe_search): Sprint 16.1 — lower _DAILY_LIMIT 140 → 45
One-line follow-up to Sprint 16. The _DAILY_LIMIT=140.0 in
recipe_search.py:48 was set assuming Spoonacular's free tier
was 150 pts/day. Sprint 15 round 1 (commit a3c89bf) hit the
real cap (50 pts/day) at query 28 — the 140 gate let
requests through to the upstream that Spoonacular then
402'd at, wasting user-facing time. Sprint 15 round 1
documented this as a follow-up ticket.
Fix: _DAILY_LIMIT = 45.0 (5pt safety margin under the real
50-pt free tier). Backend now 503s at the gate before
hitting the upstream roundtrip, giving the user a clear
"try again tomorrow" message instead of a 502 with
upstream detail.
Verified: docker compose up -d --build backend green.
GET /api/recipes/search?q=test&limit=1 returns 502
(Spoonacular 402 upstream — expected when at the cap).
The gate at 45 prevents the user from making a 47th
request that would 503 instead of 502.
No pre-existing WIP files touched. No new runtime
dependencies. No migration. Deploy: git pull +
docker compose up -d --build backend (no frontend
rebuild, no .env change).
This commit is contained in:
@@ -45,7 +45,7 @@ router = APIRouter()
|
||||
# we don't want a race between two parallel searches.
|
||||
_quota_lock = threading.Lock()
|
||||
_points_used: float = 0.0
|
||||
_DAILY_LIMIT: float = 140.0 # 150 free, leave 10pt safety margin
|
||||
_DAILY_LIMIT: float = 45.0 # 50 free, leave 5pt safety margin (corrected from 140; Sprint 15 + Sprint 16)
|
||||
_INFO_URL = "https://api.spoonacular.com/recipes/{id}/information"
|
||||
_SEARCH_URL = "https://api.spoonacular.com/recipes/complexSearch"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user