split uploads in 2 columns

This commit is contained in:
oslomp
2019-01-10 20:51:54 +01:00
parent 264ec991e5
commit 6a86cf1c0a
2 changed files with 12 additions and 5 deletions

View File

@ -50,8 +50,9 @@
</div>
<div class="row">
<div class="col-md-6">
<h2>Uploads requested by others</h2>
<h4>Total: {{stats.total_played_uploads}}</h4>
<h2>Uploads requested</h2>
<h4>Total played by you: {{stats.total_played_user_uploads}}</h4>
<h4>Total played by others: {{stats.total_played_uploads}}</h4>
<h4>Top {{ stats.stats_top_count }}:</h4>
<div class="table-responsive">
<table class="table table-striped">
@ -60,7 +61,8 @@
<th>#</th>
<th>Artist</th>
<th>Title</th>
<th># Requests</th>
<th>Others</th>
<th>You</th>
</tr>
</thead>
<tbody>
@ -70,6 +72,7 @@
<td>{{ stat.song__artist }}</td>
<td>{{ stat.song__title }}</td>
<td>{{ stat.total }}</td>
<td>{{ stat.user_total }}</td>
</tr>
{% endfor %}
</tbody>

View File

@ -145,15 +145,18 @@ def user_stats(request):
'-total')[:settings.STATS_TOP_COUNT]
most_played_uploads = PlaylistSong.objects.filter(
state=2, song_id__in=Song.objects.filter(user__id=request)).exclude(Q(user__id=None)|Q(user__id=request)).values(
state=2, song_id__in=Song.objects.filter(user__id=request)).exclude(user__id=None).values(
'song__artist',
'song__title').annotate(total=Count('id')).order_by(
'song__title').annotate(total=Count('id', filter=~Q(user__id=request)), user_total=Count('id', filter=Q(user__id=request))).order_by(
'-total', 'song__artist',
'song__title')[:settings.STATS_TOP_COUNT]
most_played = list(most_played_uploads)
total_played_uploads = 0
total_played_user_uploads = 0
for x in most_played:
total_played_uploads += x['total']
total_played_user_uploads += x['user_total']
return {
'last_updated': last_updated,
@ -165,5 +168,6 @@ def user_stats(request):
'most_played_uploads': list(most_played_uploads),
'stats_top_count': settings.STATS_TOP_COUNT,
'total_played_uploads': total_played_uploads,
'total_played_user_uploads': total_played_user_uploads,
}