impl more

main
Bel LaPointe 2024-12-15 00:48:47 -07:00
parent 58904c8619
commit 659bf0f559
1 changed files with 17 additions and 4 deletions

View File

@ -56,8 +56,21 @@ func (games Games) GamesForUser(ctx context.Context, id string) ([]string, error
return result, err
}
func (games Games) GameByName(ctx context.Context, name string) (string, error) {
return "", io.EOF
func (games Games) GameByName(ctx context.Context, uid, name string) (string, error) {
var result string
err := games.db.Query(ctx, func(rows *sql.Rows) error {
return rows.Scan(&result)
}, `
SELECT
players.games_uuid
FROM
players
JOIN games ON players.game_uuid=games.game_uuid
WHERE players.user_uuid=? AND games.name=?
ORDER BY games.timestamp DESC
LIMIT 1
`, uid, name)
return result, err
}
type (
@ -214,11 +227,11 @@ func (games Games) CreateEventAssignmentRotation(ctx context.Context, id string,
// TODO assign victim's target to killer
// TODO randomize everyone else so not the same as before AND not self
return io.EOF
return games.createEvent(ctx, id, v)
//return games.createEvent(ctx, id, v)
}
func (games Games) createEvent(ctx context.Context, id string, v any) error {
payload, err := json.Marshal(any)
payload, err := json.Marshal(v)
if err != nil {
panic(err)
}