Skip to content

Commit c7684a1

Browse files
authored
chore(kbfile): sort catalog files by descending creation time (#209)
Because - It is confusing to upload a file and then scrolling to the bottom to find it in the catalog file list This commit - Updates the list files repository method to sort by `create_time DESC`.
1 parent 6222063 commit c7684a1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/repository/knowledgebasefile.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,10 @@ func (r *Repository) ListKnowledgeBaseFiles(ctx context.Context, uid string, own
349349
query = query.Where(whereClause, kbfs[0].CreateTime)
350350
}
351351

352-
// Order by create time
353-
query = query.Order(fmt.Sprintf("%v ASC", KnowledgeBaseFileColumn.CreateTime))
352+
// Order by create time DESC
353+
// TODO INS-8162: the repository method (and the upstream handler) should
354+
// take an `ordering` parameter so clients can choose the sorting.
355+
query = query.Order(fmt.Sprintf("%v DESC", KnowledgeBaseFileColumn.CreateTime))
354356

355357
// Fetch the records
356358
if err := query.Find(&kbs).Error; err != nil {

0 commit comments

Comments
 (0)