top 20 players route returned

This commit is contained in:
nprasad2077 committed 2023-04-21 13:04:54 -05:00
1 parent 135f3cbfb9
commit c4ff08279d
2 files changed
+12 -1

No files matched your search

+10
View File
@@ -40,3 +40,13 @@ class PlayerDataByNameList(generics.ListAPIView):
def get_queryset(self):
name = self.kwargs['name']
return PlayerData.objects.filter(name__icontains=name)
# Fetch Top 20 players by PTS DESC for the season specified.
class TopScorersbySeasonList(generics.ListAPIView):
serializer_class = PlayerDataSerializer
def get_queryset(self):
season = self.kwargs['season']
return PlayerData.objects.filter(season=season).order_by('-PTS')[:20]