From 92ad5f5e90fa2d7ec1b40ad01a1841599ad9679b Mon Sep 17 00:00:00 2001 From: Teajey <21069848+Teajey@users.noreply.github.com> Date: Sat, 13 Sep 2025 00:01:36 +0900 Subject: [PATCH] Sort wishes by sent --- core/wish.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/wish.go b/core/wish.go index f7688d1..7cf705f 100644 --- a/core/wish.go +++ b/core/wish.go @@ -23,7 +23,7 @@ type Wish struct { } func (s *Session) GetWishes() ([]Wish, error) { - stmt := "SELECT wish.id, wish.name, wish.sent FROM wish WHERE wish.creator_id = ?1 AND wish.recipient_id = ?1" + stmt := "SELECT wish.id, wish.name, wish.sent FROM wish WHERE wish.creator_id = ?1 AND wish.recipient_id = ?1 ORDER BY wish.sent" rows, err := db.Connection.Query(stmt, s.User().Id) if err != nil { return nil, fmt.Errorf("Query execution failed: %w", err) @@ -110,7 +110,7 @@ func (s *Session) GetOthersWishes(userReference string) ([]Wish, error) { if otherUser.Id == s.User().Id { return nil, errors.New("Use (s *Session) GetWishes() to view your own wishes") } - stmt := "SELECT wish.id, wish.name, claimant.id, claimant.name, wish.sent, wish.creator_id, creator.name, wish.recipient_id FROM wish JOIN v_user AS user ON wish.recipient_id = user.id LEFT JOIN v_user AS claimant ON wish.claimant_id = claimant.id LEFT JOIN v_user AS creator ON wish.creator_id = creator.id WHERE user.id = ?" + stmt := "SELECT wish.id, wish.name, claimant.id, claimant.name, wish.sent, wish.creator_id, creator.name, wish.recipient_id FROM wish JOIN v_user AS user ON wish.recipient_id = user.id LEFT JOIN v_user AS claimant ON wish.claimant_id = claimant.id LEFT JOIN v_user AS creator ON wish.creator_id = creator.id WHERE user.id = ? ORDER BY wish.sent" rows, err := db.Connection.Query(stmt, otherUser.Id) if err != nil { return nil, fmt.Errorf("Failed to execute query: %w", err)