Exemplo n.º 1
0
    def forwards(self, orm):
        old_db = dbs["old"]

        round_map = migration.round_map(old_db, orm.Round)
        club_map = migration.club_map(old_db, orm.Club)

        byes = old_db.execute("select * from bye")
        tips_query = """
            select t.* from tip t
            join afl_fixture af on af.id = t.afl_fixture_id
            where af.round_id = {} and t.club_id = {}
        """

        for b in byes:
            tips = old_db.execute(tips_query.format(b[2], b[1]))

            bye_args = {"club": club_map[b[1]], "round": round_map[b[2]], "score": b[3], "winners_bonus": b[4]}

            # Add quarter scores
            scores = self.scores(tips)
            for key in ("winners", "margins", "crowds", "supercoach"):
                bye_args["{}_score".format(key)] = scores[key]

            bye = orm.Bye(**bye_args)
            bye.save()
    def forwards(self, orm):
        old_db = dbs['old']

        round_map = migration.round_map(old_db, orm.Round)
        club_map = migration.club_map(old_db, orm.Club)

        ladders = old_db.execute('select * from brownlow_ladder')

        for ladder in ladders:
            ladder_args = {
                'club':  club_map[ladder[2]],
                'position':  ladder[12],
                'previous_position':  ladder[10],
                'round':  round_map[ladder[1]],
                'score': ladder[8],
                'max_score': ladder[14],
                'min_score': ladder[0],
                'avg_score': ladder[5],
                'strike_rate': ladder[3],
                'five': ladder[9],
                'four': ladder[7],
                'three': ladder[4],
                'two': ladder[6],
                'one': ladder[13],
                'nothing': ladder[11],
            }

            new_ladder = orm.BrownlowLadder(**ladder_args)
            new_ladder.save()
Exemplo n.º 3
0
    def forwards(self, orm):
        old_db = dbs['old']

        round_map = migration.round_map(old_db, orm.Round)
        club_map = migration.club_map(old_db, orm.Club)

        ladders = old_db.execute('select * from afl_ladder')

        for ladder in ladders:
            ladder_args = {
                'club':  club_map[ladder[6]],
                'position':  ladder[10],
                'previous_position':  ladder[7],
                'round':  round_map[ladder[4]],
                'played':  ladder[3],
                'win':  ladder[5],
                'loss':  ladder[0],
                'draw':  ladder[1],
                'score_for':  ladder[8],
                'score_against':  ladder[2],
                'points':  ladder[9],
                'percentage':  ladder[11],
                }

            new_ladder = orm.AFLLadder(**ladder_args)
            new_ladder.save()
    def forwards(self, orm):
        old_db = dbs['old']

        round_map = migration.round_map(old_db, orm.Round)
        club_map = migration.club_map(old_db, orm.Club)

        ladders = old_db.execute('select * from legends_ladder')

        for ladder in ladders:
            ladder_args = {
                'club':  club_map[ladder[8]],
                'position':  ladder[16],
                'previous_position':  ladder[9],
                'round':  round_map[ladder[6]],
                'played':  ladder[3],
                'win':  ladder[7],
                'loss':  ladder[0],
                'draw':  ladder[1],
                'score_for':  ladder[10],
                'score_against':  ladder[20],
                'points':  ladder[12],
                'percentage':  ladder[17],
                'bye_for':  ladder[4],
                'total_for':  ladder[14],
                'max_for':  ladder[13],
                'min_for':  ladder[2],
                'avg_for':  ladder[15],
                'max_against':  ladder[11],
                'min_against':  ladder[5],
                'avg_against':  ladder[18],
                }

            new_ladder = orm.LegendsLadder(**ladder_args)
            new_ladder.save()
Exemplo n.º 5
0
    def forwards(self, orm):
        old_db = dbs['old']

        round_map = migration.round_map(old_db, orm.Round)
        club_map = migration.club_map(old_db, orm.Club)
        ground_map = migration.ground_map(old_db, orm.Ground)

        afl_games = old_db.execute('select * from afl_fixture')
        leg_query = 'select * from legends_fixture where afl_fixture_id = {}'
        tips_query = '''
            select t.* from tip t
            join legends_fixture lf on lf.id = t.legends_fixture_id
            join round r on r.id = lf.round_id
            where r.id = {} and t.club_id = {}
        '''

        for afl_game in afl_games:
            legends_game = old_db.execute(leg_query.format(afl_game[-1]))[0]
            away_tips = old_db.execute(
                tips_query.format(afl_game[6], legends_game[0])
            )
            home_tips = old_db.execute(
                tips_query.format(afl_game[6], legends_game[5])
            )

            game_args = {
                'crowd': afl_game[4],
                'finals_game': afl_game[10],
                'game_date': afl_game[5],
                'round': round_map[afl_game[6]],
                'status': afl_game[0],
                'tipping_deadline': afl_game[8],
                'ground': ground_map[afl_game[3]],
                'afl_away': club_map[afl_game[1]],
                'afl_away_score': afl_game[13],
                'afl_home': club_map[afl_game[9]],
                'afl_home_score': afl_game[11],
                'legends_away': club_map[legends_game[0]],
                'legends_away_score': legends_game[8],
                'legends_away_winners_bonus': legends_game[4],
                'legends_home': club_map[legends_game[5]],
                'legends_home_score': legends_game[7],
                'legends_home_winners_bonus': legends_game[1]
            }

            # Add quarter scores for legends games
            quarters = ('winners', 'margins', 'crowds', 'supercoach')
            scores = self.legends_scores(away_tips)
            for qtr in quarters:
                game_args['legends_away_{}_score'.format(qtr)] = scores[qtr]
            scores = self.legends_scores(home_tips)
            for qtr in quarters:
                game_args['legends_home_{}_score'.format(qtr)] = scores[qtr]

            game = orm.Game(**game_args)
            game.save()
    def forwards(self, orm):
        old_db = dbs["old"]

        round_map = migration.round_map(old_db, orm.Round)
        club_map = migration.club_map(old_db, orm.Club)

        ladders = old_db.execute("select * from streak_ladder")

        for ladder in ladders:
            ladder_args = {
                "club": club_map[ladder[2]],
                "position": ladder[7],
                "previous_position": ladder[1],
                "round": round_map[ladder[4]],
                "wins": ladder[5],
                "draws": ladder[3],
                "losses": ladder[6],
                "streak": ladder[0],
            }

            new_ladder = orm.StreakLadder(**ladder_args)
            new_ladder.save()
    def forwards(self, orm):
        old_db = dbs['old']

        round_map = migration.round_map(old_db, orm.Round)
        club_map = migration.club_map(old_db, orm.Club)

        ladders = old_db.execute('select * from coleman_ladder')

        for ladder in ladders:
            ladder_args = {
                'club':  club_map[ladder[1]],
                'position':  ladder[15],
                'previous_position':  ladder[19],
                'round':  round_map[ladder[12]],
                'score': ladder[11],
                'winners': ladder[13],
                'bonus': ladder[10],
                'max_score': ladder[18],
                'min_score': ladder[6],
                'avg_score': ladder[2],
                'strike_rate': ladder[8],
                'nine': ladder[21],
                'eight': ladder[22],
                'seven': ladder[0],
                'six': ladder[7],
                'five': ladder[14],
                'four': ladder[4],
                'three': ladder[9],
                'two': ladder[3],
                'one': ladder[17],
                'nothing': ladder[16],
                'bonus_strike_rate': ladder[20],
                }

            new_ladder = orm.ColemanLadder(**ladder_args)
            new_ladder.save()