mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 18:52:23 +01:00
Fix duplicate name bug on stats page
This commit is contained in:
@ -16,6 +16,7 @@ def recache_stats():
|
||||
caches['default'].set('stats', new_stats, 7200)
|
||||
return new_stats
|
||||
|
||||
|
||||
def compute_stats():
|
||||
# We want to grab the time now, because otherwise we would be reporting a minute too late
|
||||
last_updated = datetime.now()
|
||||
@ -23,9 +24,9 @@ def compute_stats():
|
||||
total_uploads = Song.objects.filter(deleted=False).exclude(
|
||||
user_id=None).count()
|
||||
|
||||
upload_stats = Song.objects.filter(
|
||||
deleted=False).exclude(user_id=None).values('user__name').annotate(
|
||||
total=Count('id')).order_by(
|
||||
upload_stats = Song.objects.filter(deleted=False).exclude(
|
||||
user_id=None).values(
|
||||
'user__id', 'user__name').annotate(total=Count('id')).order_by(
|
||||
'-total', 'user__name')[:settings.STATS_TOP_COUNT]
|
||||
|
||||
total_requests = PlaylistSong.objects.filter(state=2).exclude(
|
||||
@ -35,13 +36,13 @@ def compute_stats():
|
||||
request_stats = PlaylistSong.objects.filter(state=2).exclude(
|
||||
Q(user_id=None)
|
||||
| Q(user_id__in=settings.STATS_REQUEST_IGNORE_USER_IDS)).values(
|
||||
'user__name').annotate(total=Count('id')).order_by(
|
||||
'user__id', 'user__name').annotate(total=Count('id')).order_by(
|
||||
'-total', 'user__name')[:settings.STATS_TOP_COUNT]
|
||||
|
||||
unique_request_stats = PlaylistSong.objects.filter(state=2).exclude(
|
||||
Q(user_id=None)
|
||||
| Q(user_id__in=settings.STATS_REQUEST_IGNORE_USER_IDS)).values(
|
||||
'user__name', 'user__name').annotate(
|
||||
'user__id', 'user__name').annotate(
|
||||
total=Count('song_id', distinct=True),
|
||||
ratio=Count('song_id', distinct=True) / Count('id') *
|
||||
100).order_by('-total')[:settings.STATS_TOP_COUNT]
|
||||
|
||||
Reference in New Issue
Block a user