mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-10 09:52:22 +01:00
Extra statistic: biggest fans
This commit is contained in:
@ -107,6 +107,31 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h2>Biggest fans</h2>
|
||||||
|
<p> The people that queued your songs the most are:</p>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
|
<th>User</th>
|
||||||
|
<th style="text-align: right;"># Requests</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for stat in stats.biggest_fans %}
|
||||||
|
<tr>
|
||||||
|
<th>{{ forloop.counter }}</th>
|
||||||
|
<td>{{ stat.user__name }}</td>
|
||||||
|
<td style="text-align: right;">{{ stat.total }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -203,6 +203,14 @@ def user_stats(request):
|
|||||||
total=Count('song__user__id')).order_by(
|
total=Count('song__user__id')).order_by(
|
||||||
'-total')[:settings.STATS_TOP_COUNT]
|
'-total')[:settings.STATS_TOP_COUNT]
|
||||||
|
|
||||||
|
biggest_fans = PlaylistSong.objects.filter(
|
||||||
|
state=2, song_id__in=Song.objects.filter(user__id=request)).exclude(
|
||||||
|
Q(user_id=None)
|
||||||
|
| Q(user_id__in=settings.STATS_REQUEST_IGNORE_USER_IDS)).values(
|
||||||
|
'user__id', 'user__name').annotate(
|
||||||
|
total=Count('user__id')).order_by(
|
||||||
|
'-total')[:settings.STATS_TOP_COUNT]
|
||||||
|
|
||||||
most_played_uploads = PlaylistSong.objects.filter(
|
most_played_uploads = PlaylistSong.objects.filter(
|
||||||
state=2, song_id__in=Song.objects.filter(user__id=request)).exclude(
|
state=2, song_id__in=Song.objects.filter(user__id=request)).exclude(
|
||||||
user__id=None).values('song__artist', 'song__title').annotate(
|
user__id=None).values('song__artist', 'song__title').annotate(
|
||||||
@ -230,4 +238,5 @@ def user_stats(request):
|
|||||||
'stats_top_count': settings.STATS_TOP_COUNT,
|
'stats_top_count': settings.STATS_TOP_COUNT,
|
||||||
'total_played_uploads': total_played_uploads,
|
'total_played_uploads': total_played_uploads,
|
||||||
'total_played_user_uploads': total_played_user_uploads,
|
'total_played_user_uploads': total_played_user_uploads,
|
||||||
|
'biggest_fans': list(biggest_fans),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user