mirror of
https://github.com/nprasad2077/nbaStats.git
synced 2026-11-14 05:43:47 +00:00
3 files changed
+13
-13
No files matched your search
@@ -27,7 +27,7 @@ from nba_data.models import PlayerPlayoffAdvancedData
|
|||||||
# Change LAC to SDC for 1984 and prior.
|
# Change LAC to SDC for 1984 and prior.
|
||||||
|
|
||||||
|
|
||||||
teams = ['HOU' ,'PHI', 'BOS', 'NYK', 'BRK', 'TOR', 'MEM', 'NOP', 'DAL', 'SAS', 'DEN', 'MIN', 'OKC', 'UTA', 'POR', 'MIL', 'CLE', 'CHI', 'IND', 'DET', 'SAC', 'PHO', 'GSW', 'LAC', 'LAL', 'MIA', 'ATL', 'WAS', 'ORL', 'CHA']
|
teams = ['ATL', 'BOS', 'BRK', 'CHI', 'CHO', 'CLE', 'DAL', 'DEN', 'DET', 'GSW', 'HOU', 'IND', 'LAC', 'LAL', 'MEM', 'MIA', 'MIL', 'MIN', 'NOP', 'NYK', 'OKC', 'ORL', 'PHI', 'PHO', 'POR', 'SAC', 'SAS', 'TOR', 'UTA', 'WAS']
|
||||||
|
|
||||||
single_team = ['GSW']
|
single_team = ['GSW']
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ django.setup()
|
|||||||
|
|
||||||
from nba_data.models import PlayerShotChartData
|
from nba_data.models import PlayerShotChartData
|
||||||
|
|
||||||
player_name = 'LeBron James'
|
player_name = 'James Harden'
|
||||||
season = 2014
|
season = 2010
|
||||||
# team = 'LAL' # You might want to find a way to get this from the webpage
|
# team = 'LAL' # You might want to find a way to get this from the webpage
|
||||||
url = 'https://www.basketball-reference.com/players/j/jamesle01/shooting/' + \
|
url = 'https://www.basketball-reference.com/players/h/hardeja01/shooting/' + \
|
||||||
str(season)
|
str(season)
|
||||||
|
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
@@ -110,4 +110,4 @@ try:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error inserting data into database: {e}")
|
print(f"Error inserting data into database: {e}")
|
||||||
|
|
||||||
print('success')
|
print(f"success {player_name} {season}")
|
||||||
+8
-8
@@ -30,22 +30,22 @@ class PlayerDataByTeamList(generics.ListAPIView):
|
|||||||
return PlayerData.objects.filter(team=team)
|
return PlayerData.objects.filter(team=team)
|
||||||
|
|
||||||
|
|
||||||
# Fetch player data by season
|
# Fetch player totals data by season
|
||||||
class PlayerDataBySeasonList(generics.ListAPIView):
|
class PlayerDataBySeasonList(generics.ListAPIView):
|
||||||
serializer_class = PlayerDataSerializer
|
serializer_class = PlayerTotalsDataSerializer
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
season = self.kwargs['season']
|
season = self.kwargs['season']
|
||||||
return PlayerData.objects.filter(season=season)
|
return PlayerTotalsData.objects.filter(season=season)
|
||||||
|
|
||||||
|
|
||||||
# Fetch player data by player name
|
# Fetch player totals data by player name
|
||||||
class PlayerDataByNameList(generics.ListAPIView):
|
class PlayerDataByNameList(generics.ListAPIView):
|
||||||
serializer_class = PlayerDataSerializer
|
serializer_class = PlayerTotalsDataSerializer
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
name = self.kwargs['name']
|
name = self.kwargs['name']
|
||||||
return PlayerData.objects.filter(name__icontains=name)
|
return PlayerTotalsData.objects.filter(player_name__icontains=name)
|
||||||
|
|
||||||
|
|
||||||
# Fetch Top 20 players by PTS DESC for the season specified.
|
# Fetch Top 20 players by PTS DESC for the season specified.
|
||||||
@@ -62,7 +62,7 @@ class TopScorersbySeasonTotalsList(generics.ListAPIView):
|
|||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
season = self.kwargs['season']
|
season = self.kwargs['season']
|
||||||
return PlayerTotalsData.objects.filter(season=season).order_by('-PTS')[:20]
|
return PlayerTotalsData.objects.filter(season=season).order_by('-PTS')[:200]
|
||||||
|
|
||||||
|
|
||||||
# Fetch and calculate the average 3P made, 3P attemps, 2P made, 2P attempts for all players in each season.
|
# Fetch and calculate the average 3P made, 3P attemps, 2P made, 2P attempts for all players in each season.
|
||||||
@@ -631,7 +631,7 @@ class TopScorersbySeasonListPlayoffs(generics.ListAPIView):
|
|||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
season = self.kwargs['season']
|
season = self.kwargs['season']
|
||||||
return PlayerPlayoffTotalsData.objects.filter(season=season).order_by('-PTS')[:20]
|
return PlayerPlayoffTotalsData.objects.filter(season=season).order_by('-PTS')[:200]
|
||||||
|
|
||||||
|
|
||||||
class TopAssistsBySeasonListPlayoffs(generics.ListAPIView):
|
class TopAssistsBySeasonListPlayoffs(generics.ListAPIView):
|
||||||
|
|||||||
Reference in new issue
Block a user