diff --git a/marietje/stats/templates/stats/user.html b/marietje/stats/templates/stats/user.html index f0bff7d..d6a877c 100644 --- a/marietje/stats/templates/stats/user.html +++ b/marietje/stats/templates/stats/user.html @@ -50,8 +50,9 @@
-

Uploads requested by others

-

Total: {{stats.total_played_uploads}}

+

Uploads requested

+

Total played by you: {{stats.total_played_user_uploads}}

+

Total played by others: {{stats.total_played_uploads}}

Top {{ stats.stats_top_count }}:

@@ -60,7 +61,8 @@ - + + @@ -70,6 +72,7 @@ + {% endfor %} diff --git a/marietje/stats/utils.py b/marietje/stats/utils.py index 79a7542..08730c5 100644 --- a/marietje/stats/utils.py +++ b/marietje/stats/utils.py @@ -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, }
# Artist Title# RequestsOthersYou
{{ stat.song__artist }} {{ stat.song__title }} {{ stat.total }}{{ stat.user_total }}