add views for 2p 3p data

This commit is contained in:
nprasad2077 committed 2023-04-22 18:05:58 -05:00
1 parent 08e60d6838
commit c9711ddd19
2 files changed
+3 -2

No files matched your search

+2 -1
View File
@@ -1,5 +1,5 @@
from django.urls import path
from .views import PlayerDataList, PlayerDataByTeamList, PlayerDataBySeasonList, PlayerDataByNameList, TopScorersbySeasonList
from .views import PlayerDataList, PlayerDataByTeamList, PlayerDataBySeasonList, PlayerDataByNameList, TopScorersbySeasonList, ThreeTwoTopPointTrends
urlpatterns = [
path('api/playerdata/', PlayerDataList.as_view(), name='playerdata_list'),
@@ -7,4 +7,5 @@ urlpatterns = [
path('api/playerdata/season/<str:season>/', PlayerDataBySeasonList.as_view(), name='playerdata_by_season'),
path('api/playerdata/name/<str:name>/', PlayerDataByNameList.as_view(), name='playerdata_by_name'),
path('api/playerdata/topscorers/season/<str:season>/', TopScorersbySeasonList.as_view(), name='top_scorers_by_season'),
path('api/three_two_point_trends/', ThreeTwoTopPointTrends.as_view(), name='three_two_point_trends'),
]
+1 -1
View File
@@ -56,7 +56,7 @@ class TopScorersbySeasonList(generics.ListAPIView):
# Fetch and calculate the average 3P made, 3P attemps, 2P made, 2P attempts for all players in each season.
# Will use APIview here instead of generics.ListAPIView to avoid having to create a serializer to generate the queryset. avg_three_made and avg_two_made are new data points at the time of creation when compared to the per_game model.
class ThreeTopPointTrends(APIView):
class ThreeTwoTopPointTrends(APIView):
def get(self, request, format=None):
seasons = PlayerData.objects.values_list(
'season', flat=True).distinct().order_by('season')