diff --git a/marietje/stats/templates/stats/stats.html b/marietje/stats/templates/stats/stats.html
index 4b6a47b..eaa361c 100644
--- a/marietje/stats/templates/stats/stats.html
+++ b/marietje/stats/templates/stats/stats.html
@@ -5,46 +5,54 @@
{% block content %}
-
-
-
- | # |
- User |
- # Requests |
-
-
-
- {% for stat in request_stats %}
-
- | {{ forloop.counter }} |
- {{ stat.user__name }} |
- {{ stat.total }} |
-
- {% endfor %}
-
-
+
+
+
Uploads
+
Total: {{ total_uploads }}
+
+
+
+
+ | # |
+ User |
+ # Songs |
+
+
+
+ {% for stat in upload_stats %}
+
+ | {{ forloop.counter }} |
+ {{ stat.user__name }} |
+ {{ stat.total }} ({% widthratio stat.total total_uploads 100 %}%) |
+
+ {% endfor %}
+
+
+
+
+
+
Requests
+
Total: {{ total_requests }}
+
+
+
+
+ | # |
+ User |
+ # Requests |
+
+
+
+ {% for stat in request_stats %}
+
+ | {{ forloop.counter }} |
+ {{ stat.user__name }} |
+ {{ stat.total }} ({% widthratio stat.total total_requests 100 %}%) |
+
+ {% endfor %}
+
+
+
+
{% endblock %}
diff --git a/marietje/stats/views.py b/marietje/stats/views.py
index 0b4b27d..740c5f0 100644
--- a/marietje/stats/views.py
+++ b/marietje/stats/views.py
@@ -5,6 +5,11 @@ from queues.models import PlaylistSong
def stats(request):
- upload_stats = Song.objects.all().exclude(user_id=None).values('user__name').annotate(total=Count('id')).order_by('-total')
- request_stats = PlaylistSong.objects.all().exclude(user_id=None).values('user__name').annotate(total=Count('id')).order_by('-total')
- return render(request, 'stats/stats.html', {'upload_stats': upload_stats, 'request_stats': request_stats})
+ 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})