feat: auto-sync full lotto history on stats api access
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user