mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 21:02:24 +01:00
fix indentations
This commit is contained in:
@ -18,8 +18,9 @@ def recache_stats():
|
|||||||
|
|
||||||
|
|
||||||
def recache_user_stats():
|
def recache_user_stats():
|
||||||
users = User.objects.exclude(Q(id=None)
|
users = User.objects.exclude(
|
||||||
| Q(id__in=settings.STATS_REQUEST_IGNORE_USER_IDS)).values('id')
|
Q(id=None)
|
||||||
|
| Q(id__in=settings.STATS_REQUEST_IGNORE_USER_IDS)).values('id')
|
||||||
for user in users:
|
for user in users:
|
||||||
new_stats = user_stats(user['id'])
|
new_stats = user_stats(user['id'])
|
||||||
cacheloc = 'userstats_{}'.format(user['id'])
|
cacheloc = 'userstats_{}'.format(user['id'])
|
||||||
@ -35,9 +36,11 @@ def best_uploaders_list(requests_uploader, most_requested_uploaders):
|
|||||||
while b <= a:
|
while b <= a:
|
||||||
if b == a:
|
if b == a:
|
||||||
adding_list_item(most_requested_uploaders, requests)
|
adding_list_item(most_requested_uploaders, requests)
|
||||||
elif requests['song__user__id'] == most_requested_uploaders[b]['id']:
|
elif requests[
|
||||||
|
'song__user__id'] == most_requested_uploaders[b]['id']:
|
||||||
if requests['song__user__name'] == requests['user__name']:
|
if requests['song__user__name'] == requests['user__name']:
|
||||||
most_requested_uploaders[b]['own_total'] = requests['total']
|
most_requested_uploaders[b][
|
||||||
|
'own_total'] = requests['total']
|
||||||
else:
|
else:
|
||||||
most_requested_uploaders[b]['total'] += requests['total']
|
most_requested_uploaders[b]['total'] += requests['total']
|
||||||
break
|
break
|
||||||
@ -53,9 +56,9 @@ def adding_list_item(most_requested_list, requests):
|
|||||||
'own_total': 0
|
'own_total': 0
|
||||||
})
|
})
|
||||||
if requests['song__user__id'] == requests['user__id']:
|
if requests['song__user__id'] == requests['user__id']:
|
||||||
most_requested_list[-1]['own_total']: requests['total']
|
most_requested_list[-1]['own_total'] = requests['total']
|
||||||
else:
|
else:
|
||||||
most_requested_list[-1]['_total']: requests['total']
|
most_requested_list[-1]['total'] = requests['total']
|
||||||
|
|
||||||
|
|
||||||
def compute_stats():
|
def compute_stats():
|
||||||
@ -124,7 +127,8 @@ def compute_stats():
|
|||||||
total_time_overall = sum(x['avg_dur'] for x in list(time_requested))
|
total_time_overall = sum(x['avg_dur'] for x in list(time_requested))
|
||||||
total_average = total_time_overall / len(time_requested)
|
total_average = total_time_overall / len(time_requested)
|
||||||
avg_dur_min, avg_dur_sec = divmod(total_average, 60)
|
avg_dur_min, avg_dur_sec = divmod(total_average, 60)
|
||||||
total_average = '{} minutes and {} seconds'.format(avg_dur_min, avg_dur_sec)
|
total_average = '{} minutes and {} seconds'.format(
|
||||||
|
avg_dur_min, avg_dur_sec)
|
||||||
|
|
||||||
requests_uploader = PlaylistSong.objects.filter(state=2).exclude(
|
requests_uploader = PlaylistSong.objects.filter(state=2).exclude(
|
||||||
Q(user_id=None)
|
Q(user_id=None)
|
||||||
@ -159,7 +163,8 @@ def compute_stats():
|
|||||||
'most_played_songs': list(most_played_songs),
|
'most_played_songs': list(most_played_songs),
|
||||||
'most_played_songs_14_days': list(most_played_songs_14_days),
|
'most_played_songs_14_days': list(most_played_songs_14_days),
|
||||||
'time_requested': time_requested,
|
'time_requested': time_requested,
|
||||||
'total_time_requested': str(round(float(total_time_requested['total']) / 86400, 2)) + ' days',
|
'total_time_requested': str(round(float(
|
||||||
|
total_time_requested['total']) / 86400, 2)) + ' days',
|
||||||
'stats_top_count': settings.STATS_TOP_COUNT,
|
'stats_top_count': settings.STATS_TOP_COUNT,
|
||||||
'most_requested_uploaders': list(most_requested_uploaders),
|
'most_requested_uploaders': list(most_requested_uploaders),
|
||||||
'total_average': total_average,
|
'total_average': total_average,
|
||||||
@ -222,4 +227,4 @@ def user_stats(request):
|
|||||||
'stats_top_count': settings.STATS_TOP_COUNT,
|
'stats_top_count': settings.STATS_TOP_COUNT,
|
||||||
'total_played_uploads': total_played_uploads,
|
'total_played_uploads': total_played_uploads,
|
||||||
'total_played_user_uploads': total_played_user_uploads,
|
'total_played_user_uploads': total_played_user_uploads,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user