lotto lab 전 차수 로또 당첨 번호 그래프 시각화 api 추가
This commit is contained in:
@@ -116,6 +116,33 @@ def api_draw(drw_no: int):
|
|||||||
def admin_sync_latest():
|
def admin_sync_latest():
|
||||||
return sync_latest(LATEST_URL)
|
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) ----------
|
# ---------- ✅ recommend (dedup save) ----------
|
||||||
@app.get("/api/lotto/recommend")
|
@app.get("/api/lotto/recommend")
|
||||||
def api_recommend(
|
def api_recommend(
|
||||||
|
|||||||
Reference in New Issue
Block a user