Enha: cron for cleaning rooms from players

This commit is contained in:
Grail Finder
2025-07-06 10:13:38 +03:00
parent a685686b32
commit a38472a685
3 changed files with 103 additions and 52 deletions

View File

@ -17,6 +17,7 @@ type PlayersRepo interface {
PlayerExitRoom(ctx context.Context, username string) error
PlayerListNames(ctx context.Context) ([]string, error)
PlayerList(ctx context.Context, isBot bool) ([]models.Player, error)
PlayerListAll(ctx context.Context) ([]models.Player, error)
PlayerListByRoom(ctx context.Context, roomID string) ([]models.Player, error)
}
@ -95,6 +96,16 @@ func (p *RepoProvider) PlayerList(ctx context.Context, isBot bool) ([]models.Pla
return players, nil
}
func (p *RepoProvider) PlayerListAll(ctx context.Context) ([]models.Player, error) {
var players []models.Player
query := "SELECT id, room_id, username, team, role, is_bot FROM players;"
err := sqlx.SelectContext(ctx, p.DB, &players, query)
if err != nil {
return nil, err
}
return players, nil
}
func (p *RepoProvider) PlayerListByRoom(ctx context.Context, roomID string) ([]models.Player, error) {
var players []models.Player
err := sqlx.SelectContext(ctx, p.DB, &players, "SELECT id, room_id, username, team, role, is_bot FROM players WHERE room_id = ?", roomID)