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()
示例#2
0
    def forwards(self, orm):
        old_db = dbs['old']

        club_map = migration.club_map(old_db, orm.Club)
        season_map = migration.season_map(old_db, orm.Season)

        # Get the asistant coaches
        assistants = set(
            ('Bernard Bialecki', 'Ben West', 'Peter Moran', 'Chris Balkos')
        )

        coaches = old_db.execute('select * from coach')

        for c in coaches:
            name = '{} {}'.format(c[0], c[1])
            is_assistant = name in assistants

            coach = orm.Coach(
                club=club_map[c[3]],
                first_name=c[0],
                has_paid_fees=c[5],
                is_assistant=is_assistant,
                last_name=c[1],
                season=season_map[c[4]]
            )
            coach.save()
示例#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)

        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']

        season_map = migration.season_map(old_db, orm.Season)
        club_map = migration.club_map(old_db, orm.Club)

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

        for ladder in ladders:
            try:
                club = club_map[ladder[1]]
            except KeyError:
                club = None

            ladder_args = {
                'club':  club,
                'avg_score':  ladder[2],
                'position':  ladder[5],
                'score':  ladder[6],
                'season':  season_map[ladder[7]],
                'played':  ladder[8],
                'win':  ladder[9],
                'draw':  ladder[10],
                'loss':  ladder[11],
                'points_for':  ladder[12],
                'points_against':  ladder[13],
                'avg_points_for':  ladder[3],
                'avg_points_against':  ladder[4],
                'percentage':  ladder[14],
                }

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

        season_map = migration.season_map(old_db, orm.Season)
        club_map = migration.club_map(old_db, orm.Club)

        for name in ('brownlow', 'coleman', 'crowds', 'margins'):
            table = 'past_{}_ladder'.format(name)
            model = 'Past{}Ladder'.format(name.title())

            ladders = old_db.execute('select * from {}'.format(table))

            for ladder in ladders:
                try:
                    club = club_map[ladder[1]]
                except KeyError:
                    club = None

                ladder_args = {
                    'club':  club,
                    'avg_score':  ladder[2],
                    'position':  ladder[3],
                    'score':  ladder[4],
                    'season':  season_map[ladder[5]],
                    }

                new_ladder = getattr(orm, model)(**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()
    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()
示例#8
0
    def forwards(self, orm):
        old_db = dbs['old']

        club_map = migration.club_map(old_db, orm.Club)
        game_map = migration.game_map(
            old_db, orm.Game, fk_models={'round': orm.Round, 'club': orm.Club})

        tips = old_db.execute('select * from tip')

        for t in tips:
            tip_args = {
                'game': game_map[t[0]],
                'club': club_map[t[7]],
                'crowd': t[3],
                'crowds_score': t[2],
                'is_default': t[9],
                'margin': t[11],
                'margins_score': t[5],
                'total': t[10],
                'supercoach_score': t[6],
                'winner': club_map[t[8]],
                'winners_score': t[1]
            }

            tip = orm.Tip(**tip_args)
            tip.save()
示例#9
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()
示例#10
0
    def forwards(self, orm):
        old_db = dbs['old']

        club_map = migration.club_map(old_db, orm.Club)
        season_map = migration.season_map(old_db, orm.Season)

        old_players = old_db.execute("select * from player")

        for p in old_players:
            player_args = {
                'first_name': p[0],
                'last_name': p[1],
                'initial': p[2],
                'club': club_map[p[3]],
                'supercoach_name': p[4],
                'season': season_map[p[5]]
            }
            player = orm.Player(**player_args)
            player.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']

        season_map = migration.season_map(old_db, orm.Season)
        club_map = migration.club_map(old_db, orm.Club)

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

        for ladder in ladders:
            try:
                club = club_map[ladder[2]]
            except KeyError:
                club = None

            ladder_args = {
                'club':  club,
                'category':  ladder[1],
                'season':  season_map[ladder[3]],
                }

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

        season_map = migration.season_map(old_db, orm.Season)
        club_map = migration.club_map(old_db, orm.Club)

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

        for ladder in ladders:
            try:
                club = club_map[ladder[1]]
            except KeyError:
                club = None

            ladder_args = {
                'club':  club,
                'first_name':  ladder[2],
                'last_name':  ladder[3],
                'season':  season_map[ladder[4]],
                }

            new_ladder = orm.PastCoach(**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()