Fix PostgreSQL timestamp conversion for GET filters

Convert milliseconds timestamps to datetime for created_after filter
in notifications and created_after/before filters in paperdex.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-01-30 22:38:06 -06:00
parent 127c4fca65
commit e1c39cfb17
3 changed files with 12 additions and 6 deletions

View File

@ -8,7 +8,7 @@
"branch": "postgres-migration",
"totalEstimatedHours": 26,
"totalTasks": 28,
"completedTasks": 18
"completedTasks": 20
},
"context": {
"sourceDatabase": {
@ -485,7 +485,7 @@
"id": "TS-003",
"name": "Fix notifications.py GET created_after filter",
"category": "critical",
"completed": false,
"completed": true,
"file": "app/routers_v2/notifications.py",
"lines": [34, 44],
"notes": "Used for notification polling"
@ -523,7 +523,7 @@
"id": "TS-007",
"name": "Fix paperdex.py GET created_after/before filters",
"category": "high",
"completed": false,
"completed": true,
"file": "app/routers_v2/paperdex.py",
"lines": [31, 32, 48, 50],
"notes": "Used for filtering paperdex by date range"

View File

@ -42,7 +42,9 @@ async def get_notifs(
raise HTTPException(status_code=404, detail=f'There are no notifications to filter')
if created_after is not None:
all_notif = all_notif.where(Notification.created < created_after)
# Convert milliseconds timestamp to datetime for PostgreSQL comparison
created_after_dt = datetime.fromtimestamp(created_after / 1000)
all_notif = all_notif.where(Notification.created < created_after_dt)
if title is not None:
all_notif = all_notif.where(Notification.title == title)
if desc is not None:

View File

@ -45,9 +45,13 @@ async def get_paperdex(
all_sets = Cardset.select().where(Cardset.id == cardset_id)
all_dex = all_dex.where(Paperdex.player.cardset.id == cardset_id)
if created_after is not None:
all_dex = all_dex.where(Paperdex.created >= created_after)
# Convert milliseconds timestamp to datetime for PostgreSQL comparison
created_after_dt = datetime.fromtimestamp(created_after / 1000)
all_dex = all_dex.where(Paperdex.created >= created_after_dt)
if created_before is not None:
all_dex = all_dex.where(Paperdex.created <= created_before)
# Convert milliseconds timestamp to datetime for PostgreSQL comparison
created_before_dt = datetime.fromtimestamp(created_before / 1000)
all_dex = all_dex.where(Paperdex.created <= created_before_dt)
# if all_dex.count() == 0:
# db.close()