From af13dc4558b63a846368adf8ae3f61a7be77853a Mon Sep 17 00:00:00 2001 From: Teajey <21069848+Teajey@users.noreply.github.com> Date: Sat, 13 Sep 2025 01:37:54 +0900 Subject: [PATCH] Fix username display mixups --- core/api.snap.txt | 10 +++++----- core/session.go | 2 +- core/user.go | 14 +++++++------- core/wish.go | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/api.snap.txt b/core/api.snap.txt index 962d349..47671c1 100644 --- a/core/api.snap.txt +++ b/core/api.snap.txt @@ -81,12 +81,12 @@ func (u *Session) SuggestWishForUser(otherUserReference string, wishName string) func (s *Session) User() User type User struct { - Id string + Id string NormalName string - Name string - Reference string - IsAdmin bool - IsLive bool + Name string + Reference string + IsAdmin bool + IsLive bool } func GetUserByReference(reference string) (*User, error) diff --git a/core/session.go b/core/session.go index 188d328..e9c9d7a 100644 --- a/core/session.go +++ b/core/session.go @@ -27,8 +27,8 @@ func SessionFromKey(key string) (*Session, error) { var expiry string err := db.Connection.QueryRow(query, key).Scan( &s.user.Id, - &s.user.Name, &s.user.NormalName, + &s.user.Name, &s.user.Reference, &s.user.IsAdmin, &s.user.IsLive, diff --git a/core/user.go b/core/user.go index 55544d1..7302a38 100644 --- a/core/user.go +++ b/core/user.go @@ -10,13 +10,13 @@ import ( ) type User struct { - Id string - // TODO: rename to DisplayName + Id string NormalName string - Name string - Reference string - IsAdmin bool - IsLive bool + // TODO: rename to DisplayName + Name string + Reference string + IsAdmin bool + IsLive bool } func queryManyUsers(query string, args ...any) ([]User, error) { @@ -124,7 +124,7 @@ func GetUserByReference(reference string) (*User, error) { } func (u *User) GetTodo() ([]Wish, error) { - stmt := "SELECT wish.id, wish.name, wish.sent, recipient.name, recipient.reference FROM wish JOIN v_user AS user ON wish.claimant_id = user.id JOIN v_user AS recipient ON wish.recipient_id = recipient.id WHERE user.id = ? ORDER BY wish.sent ASC, wish.name" + stmt := "SELECT wish.id, wish.name, wish.sent, recipient.display_name, recipient.reference FROM wish JOIN v_user AS user ON wish.claimant_id = user.id JOIN v_user AS recipient ON wish.recipient_id = recipient.id WHERE user.id = ? ORDER BY wish.sent ASC, wish.name" rows, err := db.Connection.Query(stmt, u.Id) if err != nil { return nil, err diff --git a/core/wish.go b/core/wish.go index 7cf705f..89dd805 100644 --- a/core/wish.go +++ b/core/wish.go @@ -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 = ? ORDER BY wish.sent" + stmt := "SELECT wish.id, wish.name, claimant.id, claimant.display_name, wish.sent, wish.creator_id, creator.display_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)