fix: исправить пагинацию, используя полную точность created_at в cursor

Co-authored-by: aider (deepseek/deepseek-chat) <aider@aider.chat>
This commit is contained in:
Evgeny Bushkov
2026-10-23 18:31:22 +03:00
co-authored by aider
parent 785fde833f
commit eebecc74ff
2 changed files with 13 additions and 2 deletions
+9 -2
View File
@@ -161,6 +161,7 @@ def create_chat(
if store.get_user(mid) is None:
raise ApiError(400, "invalid_request", "Неизвестный участник чата")
chat = store.create_chat(title, member_ids)
chat.pop("_cursor_created_at", None)
return JSONResponse(chat, status_code=201)
@@ -179,7 +180,9 @@ def list_chats(
next_cursor = None
if has_more and items:
last = items[-1]
next_cursor = encode_cursor(last["created_at"], last["id"], scope)
next_cursor = encode_cursor(last["_cursor_created_at"], last["id"], scope)
for item in items:
item.pop("_cursor_created_at", None)
return {"items": items, "next_cursor": next_cursor}
@@ -197,6 +200,7 @@ def get_chat(
chat = store.get_chat(chat_id)
if chat is None:
raise ApiError(404, "not_found", "Чат не найден")
chat.pop("_cursor_created_at", None)
return chat
@@ -214,6 +218,7 @@ def create_message(
raise ApiError(404, "not_found", "Чат не найден")
text = validate_create_message(body)
message = store.add_message(chat_id, caller, text)
message.pop("_cursor_created_at", None)
return JSONResponse(message, status_code=201)
@@ -237,5 +242,7 @@ def list_messages(
next_cursor = None
if has_more and items:
last = items[-1]
next_cursor = encode_cursor(last["created_at"], last["id"], scope)
next_cursor = encode_cursor(last["_cursor_created_at"], last["id"], scope)
for item in items:
item.pop("_cursor_created_at", None)
return {"items": items, "next_cursor": next_cursor}