diff --git a/lotto/app/main.py b/lotto/app/main.py index 26571df..8b24896 100644 --- a/lotto/app/main.py +++ b/lotto/app/main.py @@ -421,6 +421,62 @@ def api_strategy_evolve(): return {"ok": True, "weights": new_weights} +# ── weight-evolver API ─────────────────────────────────────────────────────── + +@app.get("/api/lotto/evolver/status") +async def evolver_status(): + """현재 base + 이번주 trials + auto_picks 진행 상황.""" + from .weight_evolver import get_week_start + from .db import get_current_base, get_weekly_trials, get_auto_picks, get_latest_draw + ws = get_week_start() + trials = get_weekly_trials(ws) + trials_with_picks = [] + for t in trials: + picks = get_auto_picks(t["id"]) + trials_with_picks.append({**t, "picks": picks}) + latest = get_latest_draw() + return { + "week_start": ws, + "current_base": get_current_base(), + "trials": trials_with_picks, + "latest_draw": latest["drw_no"] if latest else None, + } + + +@app.get("/api/lotto/evolver/history") +async def evolver_history(weeks: int = 12): + """weight_base_history 최근 N개.""" + from .db import get_base_history + return {"items": get_base_history(limit=weeks)} + + +@app.get("/api/lotto/evolver/trials/{week_start}") +async def evolver_trials(week_start: str): + """특정 주 6 trials + 채점 결과.""" + from .db import get_weekly_trials, get_auto_picks + trials = get_weekly_trials(week_start) + out = [] + for t in trials: + picks = get_auto_picks(t["id"]) + out.append({**t, "picks": picks}) + return {"week_start": week_start, "trials": out} + + +@app.post("/api/lotto/evolver/generate-now") +async def evolver_generate_now(): + """수동 트리거 — 이번주 후보 생성.""" + from .weight_evolver import generate_weekly_candidates_and_save + candidates = generate_weekly_candidates_and_save() + return {"ok": True, "candidates_count": len(candidates), "candidates": candidates} + + +@app.post("/api/lotto/evolver/evaluate-now") +async def evolver_evaluate_now(): + """수동 회고 + 다음주 base 갱신.""" + from .weight_evolver import evaluate_weekly + return evaluate_weekly() + + # ── 스마트 추천 API ──────────────────────────────────────────────────────── @app.get("/api/lotto/recommend/smart")