Fix username display mixups #20

Merged
Teajey merged 1 commits from username-display-mixups into main 2025-09-13 04:39:08 +12:00
4 changed files with 14 additions and 14 deletions
Showing only changes of commit af13dc4558 - Show all commits

View File

@ -81,12 +81,12 @@ func (u *Session) SuggestWishForUser(otherUserReference string, wishName string)
func (s *Session) User() User func (s *Session) User() User
type User struct { type User struct {
Id string Id string
NormalName string NormalName string
Name string Name string
Reference string Reference string
IsAdmin bool IsAdmin bool
IsLive bool IsLive bool
Review

tf is this shite, Golang

tf is this shite, Golang
} }
func GetUserByReference(reference string) (*User, error) func GetUserByReference(reference string) (*User, error)

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

@ -10,13 +10,13 @@ import (
) )
type User struct { type User struct {
Id string Id string
// TODO: rename to DisplayName
NormalName string NormalName string
Name string // TODO: rename to DisplayName
Reference string Name string
IsAdmin bool Reference string
IsLive bool IsAdmin bool
IsLive bool
} }
func queryManyUsers(query string, args ...any) ([]User, error) { func queryManyUsers(query string, args ...any) ([]User, error) {
@ -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)