From 2d5972c25deefbe50b17c57eac21a9401cefa06e Mon Sep 17 00:00:00 2001 From: gahusb Date: Sun, 25 Jan 2026 23:56:00 +0900 Subject: [PATCH] =?UTF-8?q?lotto=20lab=20=EC=A0=84=20=EC=B0=A8=EC=88=98=20?= =?UTF-8?q?=EB=A1=9C=EB=98=90=20=EB=8B=B9=EC=B2=A8=20=EB=B2=88=ED=98=B8=20?= =?UTF-8?q?=EA=B7=B8=EB=9E=98=ED=94=84=20=EC=8B=9C=EA=B0=81=ED=99=94=20api?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/main.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/backend/app/main.py b/backend/app/main.py index 8b1ab94..9463059 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -116,6 +116,33 @@ def api_draw(drw_no: int): def admin_sync_latest(): return sync_latest(LATEST_URL) +@app.get("/api/lotto/stats") +def api_stats(): + draws = get_all_draw_numbers() + if not draws: + raise HTTPException(status_code=404, detail="No data yet") + + # 1~45번 빈도 초기화 + frequency = {n: 0 for n in range(1, 46)} + + total_draws = len(draws) + + for _, nums in draws: + for n in nums: + frequency[n] += 1 + + # 리스트 형태로 변환 (프론트엔드 차트용) + # x: 번호, y: 횟수 + stats = [ + {"number": n, "count": frequency[n]} + for n in range(1, 46) + ] + + return { + "total_draws": total_draws, + "frequency": stats + } + # ---------- ✅ recommend (dedup save) ---------- @app.get("/api/lotto/recommend") def api_recommend(