Beispiel #1
0
    def _fetch_stats(self):
        result = {}
        query = Team.all()
        query.filter('name !=', 'Testing Team')
        query_result = query.fetch(50)
        
        for team in query_result:
            name = (team.name).encode('ascii', 'ignore')

            if name not in result:
                result[name] = {}
            if 'offense' not in result[name]:
                result[name]['offense'] = {}
            if 'defense' not in result[name]:
                result[name]['defense'] = {}

            offense = result[name]['offense']
            offense['pass'] = int(team.offense_passing)
            offense['rush'] = int(team.offense_rushing)
            offense['first_down'] = int(team.offense_first_down)

            defense = result[name]['defense']
            defense['pass'] = int(team.defense_passing)
            defense['rush'] = int(team.defense_rushing)
            defense['first_down'] = int(team.defense_first_down)
        
        return result
Beispiel #2
0
def _upload_stats(team_name, stats):
    query = Team.all()
    query.filter('name =', team_name)
    result = query.fetch(1)

    if len(result) > 0:
        for team in result:
            team.year = Const.LAST_YEAR
            team.offense_passing = stats['offense']['pass']
            team.offense_rushing = stats['offense']['rush']
            team.offense_first_down = stats['offense']['first_down']
            team.defense_passing = stats['defense']['pass']
            team.defense_rushing = stats['defense']['rush']
            team.defense_first_down = stats['defense']['first_down']

            team.put()
    else:
        team = Team(name = team_name,
                    year = Const.LAST_YEAR,
                    offense_passing = stats['offense']['pass'],
                    offense_rushing = stats['offense']['rush'],
                    offense_first_down = stats['offense']['first_down'],
                    defense_passing = stats['defense']['pass'],
                    defense_rushing = stats['defense']['rush'],
                    defense_first_down = stats['defense']['first_down'])

        team.put()
Beispiel #3
0
def _upload_stats(team_name, stats):
    query = Team.all()
    query.filter('name =', team_name)
    result = query.fetch(1)

    if len(result) > 0:
        for team in result:
            team.year = Const.LAST_YEAR
            team.offense_passing = stats['offense']['pass']
            team.offense_rushing = stats['offense']['rush']
            team.offense_first_down = stats['offense']['first_down']
            team.defense_passing = stats['defense']['pass']
            team.defense_rushing = stats['defense']['rush']
            team.defense_first_down = stats['defense']['first_down']

            team.put()
    else:
        team = Team(name=team_name,
                    year=Const.LAST_YEAR,
                    offense_passing=stats['offense']['pass'],
                    offense_rushing=stats['offense']['rush'],
                    offense_first_down=stats['offense']['first_down'],
                    defense_passing=stats['defense']['pass'],
                    defense_rushing=stats['defense']['rush'],
                    defense_first_down=stats['defense']['first_down'])

        team.put()