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:
parent
127c4fca65
commit
e1c39cfb17
@ -8,7 +8,7 @@
|
|||||||
"branch": "postgres-migration",
|
"branch": "postgres-migration",
|
||||||
"totalEstimatedHours": 26,
|
"totalEstimatedHours": 26,
|
||||||
"totalTasks": 28,
|
"totalTasks": 28,
|
||||||
"completedTasks": 18
|
"completedTasks": 20
|
||||||
},
|
},
|
||||||
"context": {
|
"context": {
|
||||||
"sourceDatabase": {
|
"sourceDatabase": {
|
||||||
@ -485,7 +485,7 @@
|
|||||||
"id": "TS-003",
|
"id": "TS-003",
|
||||||
"name": "Fix notifications.py GET created_after filter",
|
"name": "Fix notifications.py GET created_after filter",
|
||||||
"category": "critical",
|
"category": "critical",
|
||||||
"completed": false,
|
"completed": true,
|
||||||
"file": "app/routers_v2/notifications.py",
|
"file": "app/routers_v2/notifications.py",
|
||||||
"lines": [34, 44],
|
"lines": [34, 44],
|
||||||
"notes": "Used for notification polling"
|
"notes": "Used for notification polling"
|
||||||
@ -523,7 +523,7 @@
|
|||||||
"id": "TS-007",
|
"id": "TS-007",
|
||||||
"name": "Fix paperdex.py GET created_after/before filters",
|
"name": "Fix paperdex.py GET created_after/before filters",
|
||||||
"category": "high",
|
"category": "high",
|
||||||
"completed": false,
|
"completed": true,
|
||||||
"file": "app/routers_v2/paperdex.py",
|
"file": "app/routers_v2/paperdex.py",
|
||||||
"lines": [31, 32, 48, 50],
|
"lines": [31, 32, 48, 50],
|
||||||
"notes": "Used for filtering paperdex by date range"
|
"notes": "Used for filtering paperdex by date range"
|
||||||
|
|||||||
@ -42,7 +42,9 @@ async def get_notifs(
|
|||||||
raise HTTPException(status_code=404, detail=f'There are no notifications to filter')
|
raise HTTPException(status_code=404, detail=f'There are no notifications to filter')
|
||||||
|
|
||||||
if created_after is not None:
|
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:
|
if title is not None:
|
||||||
all_notif = all_notif.where(Notification.title == title)
|
all_notif = all_notif.where(Notification.title == title)
|
||||||
if desc is not None:
|
if desc is not None:
|
||||||
|
|||||||
@ -45,9 +45,13 @@ async def get_paperdex(
|
|||||||
all_sets = Cardset.select().where(Cardset.id == cardset_id)
|
all_sets = Cardset.select().where(Cardset.id == cardset_id)
|
||||||
all_dex = all_dex.where(Paperdex.player.cardset.id == cardset_id)
|
all_dex = all_dex.where(Paperdex.player.cardset.id == cardset_id)
|
||||||
if created_after is not None:
|
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:
|
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:
|
# if all_dex.count() == 0:
|
||||||
# db.close()
|
# db.close()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user