def _load_game(session, row): if not row["date"]: return id = int(row["season"] + row["gcode"]) season = int(str(row["season"])[0:4]) awayteam = session.query(db.Query(models.Team).where("name = %s"), (row["awayteam"],)).as_dict() hometeam = session.query(db.Query(models.Team).where("name = %s"), (row["hometeam"],)).as_dict() start_time = row["game.start"] if row["game.start"] != "NA" else "" end_time = row["game.end"] if row["game.end"] != "NA" else "" game_start = parse("{} {}".format(row["date"], start_time), tzinfos=_get_tz_infos()) game_end = parse("{} {}".format(row["date"], end_time), tzinfos=_get_tz_infos()) duration = None if end_time: duration = game_end - game_start awayafteraway = bool(int(row["awayafteraway"])) awayafterhome = bool(int(row["awayafterhome"])) homeafteraway = bool(int(row["homeafteraway"])) homeafterhome = bool(int(row["homeafterhome"])) game = dict( id=id, season=season, status=int(row["status"]), away_team=awayteam.id, home_team=hometeam.id, away_score=int(row["awayscore"]), home_score=int(row["homescore"]), datetime=game_start, duration=duration, periods=int(row["periods"]), away_after_away=awayafteraway, away_after_home=awayafterhome, home_after_away=homeafteraway, home_after_home=homeafterhome, ) db._insert_dict(session, models.Game.table, game)
def _load_team(session, row): team = dict( id=int(row[""]), name=row["team"], full_name=row["TeamName"], city=row["SchedTeamName"], color=row["color"], color2=row["color2"], ) db._insert_dict(session, models.Team.table, team)