def container_from_game_row(row, offset=0): return Container(id=row[offset], number_moves_made=row[offset + 1], game_state=Board.from_dict(json.loads(row[offset + 2])), team_id=row[offset + 3], competition_id=row[offset + 4], score=row[offset + 5], finished_ts=row[offset + 6], )
def get_game_by_team_and_competition_id(self, team_id, competition_id): sql = """ SELECT id, number_moves_made, game_state, team_id, competition_id, score FROM game WHERE team_id = %s AND competition_id = %s """ self.execute(sql, (team_id, competition_id)) game_row = self.fetchone() if game_row is None: return None return Container(id=game_row[0], number_moves_made=game_row[1], game_state=Board.from_dict(json.loads(game_row[2])), team_id=game_row[3], competition_id=game_row[4])