fix chat workflow sorting for mixed timestamp types
Use parseTimestamp when sorting messages and stats so INT workflows do not fail when DB rows contain timestamp values as both strings and floats. Made-with: Cursor
This commit is contained in:
parent
3b3a44b3a4
commit
5684a4d769
1 changed files with 7 additions and 5 deletions
|
|
@ -909,9 +909,10 @@ class ChatObjects:
|
|||
"actionProgress": msg.get("actionProgress")
|
||||
})
|
||||
|
||||
# Apply default sorting by publishedAt if no sort specified
|
||||
# Apply default sorting by publishedAt if no sort specified.
|
||||
# Use parseTimestamp to tolerate mixed DB types (float/string) on INT.
|
||||
if pagination is None or not pagination.sort:
|
||||
messageDicts.sort(key=lambda x: x.get("publishedAt") or getUtcTimestamp())
|
||||
messageDicts.sort(key=lambda x: parseTimestamp(x.get("publishedAt"), default=0))
|
||||
|
||||
# Apply filtering (if filters provided)
|
||||
if pagination and pagination.filters:
|
||||
|
|
@ -1537,9 +1538,10 @@ class ChatObjects:
|
|||
if not stats:
|
||||
return []
|
||||
|
||||
# Return all stats records sorted by creation time
|
||||
# DB uses _createdAt (camelCase system field)
|
||||
stats.sort(key=lambda x: x.get("_createdAt", 0))
|
||||
# Return all stats records sorted by creation time.
|
||||
# Use parseTimestamp to tolerate mixed DB types (float/string) on INT.
|
||||
# DB uses _createdAt (camelCase system field).
|
||||
stats.sort(key=lambda x: parseTimestamp(x.get("_createdAt"), default=0))
|
||||
|
||||
# Convert to ChatStat objects, preserving _createdAt via extra="allow"
|
||||
result = []
|
||||
|
|
|
|||
Loading…
Reference in a new issue