mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-24 21:41:04 +02:00
fix: order local list_documents newest-first, matching the cloud API
The server's GET /docs/ returns createdAt DESC (id ASC tiebreak) and the cloud backend preserves that order, so list_documents()[0] meant the newest document on cloud but the oldest on local (ORDER BY created_at ascending). The same order also feeds _get_all_doc_ids' doc priority for multi-doc chat. rowid DESC tiebreaks same-second inserts by insertion order.
This commit is contained in:
parent
93535fca7e
commit
80493ccf62
1 changed files with 3 additions and 1 deletions
|
|
@ -210,7 +210,9 @@ class SQLiteStorage:
|
|||
def list_documents(self, collection: str) -> list[dict]:
|
||||
conn = self._get_conn()
|
||||
rows = conn.execute(
|
||||
"SELECT doc_id, doc_name, doc_description, doc_type FROM documents WHERE collection_name = ? ORDER BY created_at",
|
||||
# Newest first, matching the cloud API's createdAt DESC order;
|
||||
# rowid breaks same-second ties by insertion order.
|
||||
"SELECT doc_id, doc_name, doc_description, doc_type FROM documents WHERE collection_name = ? ORDER BY created_at DESC, rowid DESC",
|
||||
(collection,),
|
||||
).fetchall()
|
||||
return [{"doc_id": r[0], "doc_name": r[1], "doc_description": r[2] or "", "doc_type": r[3]} for r in rows]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue