post-game update prepare
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from django.shortcuts import render
|
||||
from django.db.models import Avg
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from playlist.models import Session, Profile, Track, Vote
|
||||
@@ -37,4 +38,5 @@ class SessionInfoView(APIView):
|
||||
def get(self, request, session_id):
|
||||
track_count = len(Track.objects.all())
|
||||
vote_count = len(Vote.objects.all())
|
||||
return Response({'track_count': track_count, 'vote_count': vote_count})
|
||||
average_vote = Vote.objects.all().aggregate(Avg("points", default=0))['points__avg']
|
||||
return Response({'track_count': track_count, 'vote_count': vote_count, 'average_vote': average_vote})
|
||||
|
||||
Reference in New Issue
Block a user