mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 21:52:21 +01:00
16 lines
895 B
Python
16 lines
895 B
Python
from django.shortcuts import render
|
|
from django.db.models import Count
|
|
from songs.models import Song
|
|
from queues.models import PlaylistSong
|
|
|
|
|
|
def stats(request):
|
|
total_uploads = Song.objects.all().filter(deleted=False).exclude(user_id=None).count()
|
|
upload_stats = Song.objects.all().filter(deleted=False).exclude(user_id=None).values('user__name')\
|
|
.annotate(total=Count('id')).order_by('-total')
|
|
total_requests = PlaylistSong.objects.all().filter(state=2).exclude(user_id=None).count()
|
|
request_stats = PlaylistSong.objects.all().filter(state=2).exclude(user_id=None).values('user__name')\
|
|
.annotate(total=Count('id')).order_by('-total')
|
|
return render(request, 'stats/stats.html', {'total_uploads': total_uploads, 'upload_stats': upload_stats,
|
|
'total_requests': total_requests, 'request_stats': request_stats})
|