Compare commits

..

2 Commits

4 changed files with 14 additions and 14 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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

View File

@ -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)