Skip to content

Commit ec00381

Browse files
committed
chore: add OrderBy to ListChat
1 parent 3901343 commit ec00381

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

internal/handler/rest/chat/list_chat.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ func (h *ListChatHandler) Handle(c *fiber.Ctx) error {
7979
query := h.deps.DB.NewSelect().
8080
Model((*domain.Chat)(nil)).
8181
Relation("Summary").
82-
Where("c.user_id = ?", userID)
82+
Where("c.user_id = ?", userID).
83+
Order("c.created_at DESC")
8384

8485
if datetimeGte != "" {
8586
localStartTime, err := time.Parse(time.RFC3339, datetimeGte)
@@ -148,6 +149,7 @@ func (h *ListChatHandler) Handle(c *fiber.Ctx) error {
148149
err := h.deps.DB.NewSelect().
149150
Model((*domain.History)(nil)).
150151
Where("chat_id = ?", chat.ID).
152+
Order("created_at ASC").
151153
Scan(ctx, &histories)
152154
if err == nil {
153155
summaryDTO := chat.Summary.ToSummaryWithTopicMessages(histories)

0 commit comments

Comments
 (0)