fix: resolve 4 logic bugs found in code review
- utc_to_eastern: use zoneinfo instead of hardcoded EDT offset (-4) so start times are correct in both EST and EDT - standings: fetch before truncate so a failed API call doesn't wipe existing standings data - routes: call parse_games() once per request instead of three times - scheduler: wrap run_pending() in try/except so an unhandled exception doesn't kill the background thread Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
10
app/games.py
10
app/games.py
@@ -1,9 +1,12 @@
|
||||
import logging
|
||||
import sqlite3
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timezone
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from app.config import DB_PATH
|
||||
|
||||
EASTERN = ZoneInfo("America/New_York")
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -226,6 +229,5 @@ def get_team_standings(team_name):
|
||||
|
||||
def utc_to_eastern(utc_time):
|
||||
utc_datetime = datetime.strptime(utc_time, "%Y-%m-%dT%H:%M:%SZ")
|
||||
est_offset = timedelta(hours=-4)
|
||||
est_datetime = utc_datetime + est_offset
|
||||
return est_datetime.strftime("%I:%M %p")
|
||||
eastern_datetime = utc_datetime.replace(tzinfo=timezone.utc).astimezone(EASTERN)
|
||||
return eastern_datetime.strftime("%I:%M %p")
|
||||
|
||||
Reference in New Issue
Block a user