fix: list_messages returns newest N (was returning oldest N)
Some checks failed
Deploy Tracker / deploy (push) Failing after 23s
Some checks failed
Deploy Tracker / deploy (push) Failing after 23s
This commit is contained in:
parent
ffca92d08a
commit
050d672836
@ -94,9 +94,12 @@ async def list_messages(
|
|||||||
if not parent_id and (chat_id or task_id):
|
if not parent_id and (chat_id or task_id):
|
||||||
q = q.where(Message.parent_id.is_(None))
|
q = q.where(Message.parent_id.is_(None))
|
||||||
|
|
||||||
q = q.order_by(Message.created_at).offset(offset).limit(limit)
|
# Get newest N messages (DESC), then reverse to chronological order
|
||||||
|
q = q.order_by(Message.created_at.desc()).offset(offset).limit(limit)
|
||||||
result = await db.execute(q)
|
result = await db.execute(q)
|
||||||
return [_message_out(m) for m in result.scalars()]
|
messages = [_message_out(m) for m in result.scalars()]
|
||||||
|
messages.reverse()
|
||||||
|
return messages
|
||||||
|
|
||||||
|
|
||||||
@router.post("/messages", response_model=MessageOut)
|
@router.post("/messages", response_model=MessageOut)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user