Fix PostgreSQL timestamp conversion for stats GET filters
Convert milliseconds to datetime for created filter in batstats.py and pitstats.py GET endpoints. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f3b0b90860
commit
f4aafa35e7
@ -8,7 +8,7 @@
|
|||||||
"branch": "postgres-migration",
|
"branch": "postgres-migration",
|
||||||
"totalEstimatedHours": 26,
|
"totalEstimatedHours": 26,
|
||||||
"totalTasks": 28,
|
"totalTasks": 28,
|
||||||
"completedTasks": 24
|
"completedTasks": 26
|
||||||
},
|
},
|
||||||
"context": {
|
"context": {
|
||||||
"sourceDatabase": {
|
"sourceDatabase": {
|
||||||
@ -568,7 +568,7 @@
|
|||||||
"id": "TS-012",
|
"id": "TS-012",
|
||||||
"name": "Fix batstats.py GET created filter",
|
"name": "Fix batstats.py GET created filter",
|
||||||
"category": "medium",
|
"category": "medium",
|
||||||
"completed": false,
|
"completed": true,
|
||||||
"file": "app/routers_v2/batstats.py",
|
"file": "app/routers_v2/batstats.py",
|
||||||
"lines": [74, 98],
|
"lines": [74, 98],
|
||||||
"notes": "Not actively used - commented out in gameplay_legacy.py"
|
"notes": "Not actively used - commented out in gameplay_legacy.py"
|
||||||
@ -577,7 +577,7 @@
|
|||||||
"id": "TS-013",
|
"id": "TS-013",
|
||||||
"name": "Fix pitstats.py GET created filter",
|
"name": "Fix pitstats.py GET created filter",
|
||||||
"category": "medium",
|
"category": "medium",
|
||||||
"completed": false,
|
"completed": true,
|
||||||
"file": "app/routers_v2/pitstats.py",
|
"file": "app/routers_v2/pitstats.py",
|
||||||
"lines": [60, 85],
|
"lines": [60, 85],
|
||||||
"notes": "Not actively used - commented out in gameplay_legacy.py"
|
"notes": "Not actively used - commented out in gameplay_legacy.py"
|
||||||
|
|||||||
@ -95,7 +95,9 @@ async def get_batstats(
|
|||||||
if week_end is not None:
|
if week_end is not None:
|
||||||
all_stats = all_stats.where(BattingStat.week <= week_end)
|
all_stats = all_stats.where(BattingStat.week <= week_end)
|
||||||
if created is not None:
|
if created is not None:
|
||||||
all_stats = all_stats.where(BattingStat.created == created)
|
# Convert milliseconds timestamp to datetime for PostgreSQL comparison
|
||||||
|
created_dt = datetime.fromtimestamp(created / 1000)
|
||||||
|
all_stats = all_stats.where(BattingStat.created == created_dt)
|
||||||
|
|
||||||
# if all_stats.count() == 0:
|
# if all_stats.count() == 0:
|
||||||
# db.close()
|
# db.close()
|
||||||
|
|||||||
@ -82,7 +82,9 @@ async def get_pit_stats(
|
|||||||
if week_end is not None:
|
if week_end is not None:
|
||||||
all_stats = all_stats.where(PitchingStat.week <= week_end)
|
all_stats = all_stats.where(PitchingStat.week <= week_end)
|
||||||
if created is not None:
|
if created is not None:
|
||||||
all_stats = all_stats.where(PitchingStat.created <= created)
|
# Convert milliseconds timestamp to datetime for PostgreSQL comparison
|
||||||
|
created_dt = datetime.fromtimestamp(created / 1000)
|
||||||
|
all_stats = all_stats.where(PitchingStat.created <= created_dt)
|
||||||
if gs is not None:
|
if gs is not None:
|
||||||
all_stats = all_stats.where(PitchingStat.gs == 1 if gs else 0)
|
all_stats = all_stats.where(PitchingStat.gs == 1 if gs else 0)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user