feat: auto-sync full lotto history on stats api access

This commit is contained in:
2026-01-26 00:45:32 +09:00
parent bd43c99221
commit 597353e6d4
3 changed files with 74 additions and 15 deletions

View File

@@ -10,7 +10,8 @@ from .db import (
update_recommendation,
)
from .recommender import recommend_numbers
from .collector import sync_latest
from .recommender import recommend_numbers
from .collector import sync_latest, sync_ensure_all
app = FastAPI()
scheduler = BackgroundScheduler(timezone=os.getenv("TZ", "Asia/Seoul"))
@@ -118,6 +119,10 @@ def admin_sync_latest():
@app.get("/api/lotto/stats")
def api_stats():
# 1. 데이터 완전성 보장 (없으면 가져옴)
sync_ensure_all(LATEST_URL, ALL_URL)
# 2. 전체 데이터 조회
draws = get_all_draw_numbers()
if not draws:
raise HTTPException(status_code=404, detail="No data yet")