mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 19:52:20 +01:00
More statistics on the stats page.
This commit is contained in:
committed by
Daan Sprenkels
parent
5ce5dc5587
commit
cbc9284865
@ -5,46 +5,54 @@
|
||||
|
||||
{% block content %}
|
||||
<h1>Statistics</h1>
|
||||
<h2>Uploads</h2>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>User</th>
|
||||
<th># Songs</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for stat in upload_stats %}
|
||||
<tr>
|
||||
<th>{{ forloop.counter }}</th>
|
||||
<td>{{ stat.user__name }}</td>
|
||||
<td>{{ stat.total }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<h2>Requests</h2>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>User</th>
|
||||
<th># Requests</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for stat in request_stats %}
|
||||
<tr>
|
||||
<th>{{ forloop.counter }}</th>
|
||||
<td>{{ stat.user__name }}</td>
|
||||
<td>{{ stat.total }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h2>Uploads</h2>
|
||||
<h4>Total: {{ total_uploads }}</h4>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>User</th>
|
||||
<th># Songs</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for stat in upload_stats %}
|
||||
<tr>
|
||||
<th>{{ forloop.counter }}</th>
|
||||
<td>{{ stat.user__name }}</td>
|
||||
<td>{{ stat.total }} ({% widthratio stat.total total_uploads 100 %}%)</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h2>Requests</h2>
|
||||
<h4>Total: {{ total_requests }}</h4>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>User</th>
|
||||
<th># Requests</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for stat in request_stats %}
|
||||
<tr>
|
||||
<th>{{ forloop.counter }}</th>
|
||||
<td>{{ stat.user__name }}</td>
|
||||
<td>{{ stat.total }} ({% widthratio stat.total total_requests 100 %}%)</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@ -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})
|
||||
|
||||
Reference in New Issue
Block a user