Merge pull request 'Fix username display mixups' (#20) from username-display-mixups into main

Reviewed-on: #20
This commit is contained in:
Thomas Williams 2025-09-13 04:39:08 +12:00
commit 24bc67a8e2
4 changed files with 14 additions and 14 deletions

View File

@ -27,8 +27,8 @@ func SessionFromKey(key string) (*Session, error) {
var expiry string var expiry string
err := db.Connection.QueryRow(query, key).Scan( err := db.Connection.QueryRow(query, key).Scan(
&s.user.Id, &s.user.Id,
&s.user.Name,
&s.user.NormalName, &s.user.NormalName,
&s.user.Name,
&s.user.Reference, &s.user.Reference,
&s.user.IsAdmin, &s.user.IsAdmin,
&s.user.IsLive, &s.user.IsLive,

View File

@ -11,8 +11,8 @@ import (
type User struct { type User struct {
Id string Id string
// TODO: rename to DisplayName
NormalName string NormalName string
// TODO: rename to DisplayName
Name string Name string
Reference string Reference string
IsAdmin bool IsAdmin bool
@ -124,7 +124,7 @@ func GetUserByReference(reference string) (*User, error) {
} }
func (u *User) GetTodo() ([]Wish, 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) rows, err := db.Connection.Query(stmt, u.Id)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -110,7 +110,7 @@ func (s *Session) GetOthersWishes(userReference string) ([]Wish, error) {
if otherUser.Id == s.User().Id { if otherUser.Id == s.User().Id {
return nil, errors.New("Use (s *Session) GetWishes() to view your own wishes") 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) rows, err := db.Connection.Query(stmt, otherUser.Id)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to execute query: %w", err) return nil, fmt.Errorf("Failed to execute query: %w", err)