Fix: buildable
This commit is contained in:
		| @@ -12,6 +12,17 @@ type PlayersRepo interface { | ||||
| 	PlayerDelete(roomID, username string) error | ||||
| 	PlayerSetRoomID(username, roomID string) error | ||||
| 	PlayerExitRoom(username string) error | ||||
| 	PlayerListNames() ([]string, error) | ||||
| 	PlayerList(isBot bool) ([]models.Player, error) | ||||
| } | ||||
|  | ||||
| func (p *RepoProvider) PlayerListNames() ([]string, error) { | ||||
| 	var names []string | ||||
| 	err := p.DB.SelectContext(context.Background(), &names, "SELECT username FROM players;") | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return names, nil | ||||
| } | ||||
|  | ||||
| func (p *RepoProvider) PlayerGetByName(username string) (*models.Player, error) { | ||||
| @@ -49,3 +60,18 @@ func (p *RepoProvider) PlayerExitRoom(username string) error { | ||||
| 	_, err := p.DB.ExecContext(context.Background(), "UPDATE players SET room_id = null WHERE username = ?", username) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| func (p *RepoProvider) PlayerList(isBot bool) ([]models.Player, error) { | ||||
| 	var players []models.Player | ||||
| 	var query string | ||||
| 	if isBot { | ||||
| 		query = "SELECT id, room_id, username, team, role, is_bot FROM players WHERE is_bot = true;" | ||||
| 	} else { | ||||
| 		query = "SELECT id, room_id, username, team, role, is_bot FROM players WHERE is_bot = false;" | ||||
| 	} | ||||
| 	err := p.DB.SelectContext(context.Background(), &players, query) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return players, nil | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder