Use RSVP #15

Merged
Teajey merged 14 commits from rsvp-lib into main 2025-09-13 03:06:22 +12:00
1 changed files with 2 additions and 2 deletions
Showing only changes of commit 92ad5f5e90 - Show all commits

View File

@ -23,7 +23,7 @@ type Wish struct {
} }
func (s *Session) GetWishes() ([]Wish, error) { 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) rows, err := db.Connection.Query(stmt, s.User().Id)
if err != nil { if err != nil {
return nil, fmt.Errorf("Query execution failed: %w", err) 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 { 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 = ?" 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) 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)