stats/player_game_log.py
def fetch_season(self, season_id):
        """
        Build GET REST request to the NBA for a season,
        iterate over the results,
        store in the database.
        """
        params = self.build_params(season_id)

        # Encode without safe '+', apparently the NBA likes unsafe url params.
        params_str = urllib.parse.urlencode(params, safe=':+')

        response = requests.get(url=self.url, headers=headers, params=params_str).json()

        result_sets = response['resultSets'][0]
        rowset = result_sets['rowSet']

        season_int = season_id_to_int(season_id)
        column_names = column_names_from_table(self.settings.db, self.table._meta.table_name)

        column_mapping = get_rowset_mapping(result_sets, column_names)

        rowset_mapping = get_rowset_mapping(result_sets, self.local_resultset_rows())

        # looping over data to insert into table
        for row in rowset:

            matchup = row[rowset_mapping['MATCHUP']]
            wl = row[rowset_mapping['WL']]
            team_id = row[rowset_mapping['TEAM_ID']]
            game_date = row[rowset_mapping['GAME_DATE']]
            game_id = row[rowset_mapping['GAME_ID']]

            # Checking matchup for home team.
            if '@' in matchup:
                if wl == "W":
                    winner = team_id
                    loser = ""
                else:
                    winner = ""
                    loser = team_id
                self.game_set.add(
                    GameEntry(
                        season_id=season_int, 
                        game_id=game_id,
                        game_date=game_date,
                        matchup_in=matchup,
                        winner=winner, 
                        loser=loser))

            new_row = {column_name: row[row_index] for column_name, row_index in column_mapping.items()}
            new_row['season_id'] = season_int
            self.rows.append(new_row)

        Build GET REST request to the NBA for a season,
        iterate over the results,
        store in the database.
        
Build GET REST request to the NBA for a season,
iterate over the results,
store in the database.
Build GET REST request to the NBA for a season iterate over the results store in the database .
def fetch_season(self, season_id):
        params = self.build_params(season_id)
        params_str = urllib.parse.urlencode(params, safe=':+')
        response = requests.get(url=self.url, headers=headers, params=params_str).json()
        result_sets = response['resultSets'][0]
        rowset = result_sets['rowSet']
        season_int = season_id_to_int(season_id)
        column_names = column_names_from_table(self.settings.db, self.table._meta.table_name)
        column_mapping = get_rowset_mapping(result_sets, column_names)
        rowset_mapping = get_rowset_mapping(result_sets, self.local_resultset_rows())
        for row in rowset:
            matchup = row[rowset_mapping['MATCHUP']]
            wl = row[rowset_mapping['WL']]
            team_id = row[rowset_mapping['TEAM_ID']]
            game_date = row[rowset_mapping['GAME_DATE']]
            game_id = row[rowset_mapping['GAME_ID']]
            if '@' in matchup:
                if wl == "W":
                    winner = team_id
                    loser = ""
                else:
                    winner = ""
                    loser = team_id
                self.game_set.add(
                    GameEntry(
                        season_id=season_int, 
                        game_id=game_id,
                        game_date=game_date,
                        matchup_in=matchup,
                        winner=winner, 
                        loser=loser))
            new_row = {column_name: row[row_index] for column_name, row_index in column_mapping.items()}
            new_row['season_id'] = season_int
            self.rows.append(new_row)
def fetch_season ( self , season_id ) : params = self . build_params ( season_id ) params_str = urllib . parse . urlencode ( params , safe = ':+' ) response = requests . get ( url = self . url , headers = headers , params = params_str ) . json ( ) result_sets = response [ 'resultSets' ] [ 0 ] rowset = result_sets [ 'rowSet' ] season_int = season_id_to_int ( season_id ) column_names = column_names_from_table ( self . settings . db , self . table . _meta . table_name ) column_mapping = get_rowset_mapping ( result_sets , column_names ) rowset_mapping = get_rowset_mapping ( result_sets , self . local_resultset_rows ( ) ) for row in rowset : matchup = row [ rowset_mapping [ 'MATCHUP' ] ] wl = row [ rowset_mapping [ 'WL' ] ] team_id = row [ rowset_mapping [ 'TEAM_ID' ] ] game_date = row [ rowset_mapping [ 'GAME_DATE' ] ] game_id = row [ rowset_mapping [ 'GAME_ID' ] ] if '@' in matchup : if wl == "W" : winner = team_id loser = "" else : winner = "" loser = team_id self . game_set . add ( GameEntry ( season_id = season_int , game_id = game_id , game_date = game_date , matchup_in = matchup , winner = winner , loser = loser ) ) new_row = { column_name : row [ row_index ] for column_name , row_index in column_mapping . items ( ) } new_row [ 'season_id' ] = season_int self . rows . append ( new_row )
Build GET REST request to the NBA for a season,
iterate over the results,
store in the database.
Build GET REST request to the NBA for a season iterate over the results store in the database .
"""
        Build GET REST request to the NBA for a season,
        iterate over the results,
        store in the database.
        """ # Encode without safe '+', apparently the NBA likes unsafe url params. # looping over data to insert into table # Checking matchup for home team.
self
season_id