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