Limit user stat list size

This commit is contained in:
Daan Sprenkels
2018-12-14 17:29:50 +01:00
parent 6153a09277
commit 298c89fc4d

View File

@ -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'))