05/23 Phase 22

This commit is contained in:
2026-05-23 17:36:33 -04:00
parent edd2ed5660
commit 59789f3cfe
10 changed files with 358 additions and 23 deletions
+9 -1
View File
@@ -14,7 +14,7 @@ import threading
import requests
from datetime import datetime
from db.models import get_game_by_name, insert_draw, insert_fetch_log
from db.models import get_game_by_name, get_last_draw, insert_draw, insert_fetch_log
logger = logging.getLogger(__name__)
@@ -262,6 +262,10 @@ def _fetch_va_lottery(game_name: str, source: str, url: str) -> dict:
game_id = game["id"]
added = skipped = 0
# Incremental fetch: VA data is newest-first; stop once we reach known dates
last_draw = get_last_draw(game_id)
last_date = last_draw["draw_date"] if last_draw else None
try:
resp = requests.get(url, timeout=30)
resp.raise_for_status()
@@ -279,6 +283,10 @@ def _fetch_va_lottery(game_name: str, source: str, url: str) -> dict:
if draw_date is None:
continue
# Data comes newest-first; stop when we reach already-stored dates
if last_date and draw_date <= last_date:
break
try:
p1 = parts[1].strip()
p1_lower = p1.lower()