diff --git a/marietje/stats/utils.py b/marietje/stats/utils.py index 3f5d542..a4cae4b 100644 --- a/marietje/stats/utils.py +++ b/marietje/stats/utils.py @@ -133,14 +133,16 @@ def user_stats(request): | Q(user_id__in=settings.STATS_REQUEST_IGNORE_USER_IDS)).values( 'song__artist', 'song__title').annotate(total=Count('id')).order_by( - '-total', 'song__artist', 'song__title') + '-total', 'song__artist', + 'song__title')[:settings.STATS_TOP_COUNT] most_played_uploaders = PlaylistSong.objects.filter( user__id=request, state=2).exclude( Q(user_id=None) | Q(user_id__in=settings.STATS_REQUEST_IGNORE_USER_IDS)).values( 'song__user__id', 'song__user__name').annotate( - total=Count('song__user__id')).order_by('-total') + total=Count('song__user__id')).order_by( + '-total')[:settings.STATS_TOP_COUNT] most_played_uploads = PlaylistSong.objects.filter( state=2, song_id__in=Song.objects.filter(user__id=request)).exclude( @@ -149,7 +151,8 @@ def user_stats(request): 'pk').values( 'song__artist', 'song__title').annotate(total=Count('id')).order_by( - '-total', 'song__artist', 'song__title') + '-total', 'song__artist', + 'song__title')[:settings.STATS_TOP_COUNT] total_played_uploads = most_played_uploads.aggregate(newtotal=Sum('total'))