Feat: stats [WIP]
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
|
||||
type PlayerStatsRepo interface {
|
||||
GetPlayerStats(ctx context.Context, username string) (*models.PlayerStats, error)
|
||||
GetAllPlayerStats(ctx context.Context) ([]*models.PlayerStats, error)
|
||||
UpdatePlayerStats(ctx context.Context, stats *models.PlayerStats) error
|
||||
CreatePlayerStats(ctx context.Context, username string) error
|
||||
}
|
||||
@ -19,6 +20,12 @@ func (p *RepoProvider) GetPlayerStats(ctx context.Context, username string) (*mo
|
||||
return stats, err
|
||||
}
|
||||
|
||||
func (p *RepoProvider) GetAllPlayerStats(ctx context.Context) ([]*models.PlayerStats, error) {
|
||||
var stats []*models.PlayerStats
|
||||
err := sqlx.SelectContext(ctx, p.DB, &stats, "SELECT * FROM player_stats ORDER BY games_won DESC")
|
||||
return stats, err
|
||||
}
|
||||
|
||||
func (p *RepoProvider) UpdatePlayerStats(ctx context.Context, stats *models.PlayerStats) error {
|
||||
_, err := p.DB.NamedExecContext(ctx, `UPDATE player_stats SET
|
||||
games_played = :games_played,
|
||||
|
Reference in New Issue
Block a user