add top ORB/DRB views and urls

This commit is contained in:
nprasad2077 committed 2023-04-26 14:56:07 -05:00
1 parent 38c37a3df2
commit 92cfd0af0f
2 files changed
+23 -1

No files matched your search

+3 -1
View File
@@ -1,5 +1,5 @@
from django.urls import path
from .views import PlayerDataList, PlayerDataByTeamList, PlayerDataBySeasonList, PlayerDataByNameList, TopScorersbySeasonList, ThreeTwoTopPointTrends, TopAssistsBySeasonList, TopReboundsBySeasonList, TopBlocksBySeasonList, TopStealsBySeasonList
from .views import PlayerDataList, PlayerDataByTeamList, PlayerDataBySeasonList, PlayerDataByNameList, TopScorersbySeasonList, ThreeTwoTopPointTrends, TopAssistsBySeasonList, TopReboundsBySeasonList, TopBlocksBySeasonList, TopStealsBySeasonList, TopOffensiveReboundsBySeasonList, TopDefensiveReboundsBySeasonList
urlpatterns = [
path('api/playerdata/', PlayerDataList.as_view(), name='playerdata_list'),
@@ -12,4 +12,6 @@ urlpatterns = [
path('api/top_rebounds/<int:season>/', TopReboundsBySeasonList.as_view(), name='top_rebounds'),
path('api/top_blocks/<int:season>/', TopBlocksBySeasonList.as_view(), name='top_blocks'),
path('api/top_steals/<int:season>/', TopStealsBySeasonList.as_view(), name='top_steals'),
path('api/top_rebounds_offensive/<int:season>/', TopOffensiveReboundsBySeasonList.as_view(), name='top_rebounds_ORB'),
path('api/top_rebounds_defensive/<int:season>/', TopDefensiveReboundsBySeasonList.as_view(), name='top_rebounds_DRB'),
]
+20
View File
@@ -121,3 +121,23 @@ class TopStealsBySeasonList(generics.ListAPIView):
def get_queryset(self):
season = self.kwargs['season']
return PlayerData.objects.filter(season=season).order_by('-STL')[:20]
# Fetch Top 20 players by ORB DESC for season.
class TopOffensiveReboundsBySeasonList(generics.ListAPIView):
serializer_class = PlayerDataSerializer
def get_queryset(self):
season = self.kwargs['season']
return PlayerData.objects.filter(season=season).order_by('-ORB')[:20]
# Fetch Top 20 players by DRB DESC for season.
class TopDefensiveReboundsBySeasonList(generics.ListAPIView):
serializer_class = PlayerDataSerializer
def get_queryset(self):
season = self.kwargs['season']
return PlayerData.objects.filter(season=season).order_by('-DRB')[:20]