mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-10 09:42:20 +01:00
Oslomp/stats bugfixes
This commit is contained in:
committed by
Gerdriaan Mulder
parent
409c5b2930
commit
3f263ae429
@ -56,7 +56,6 @@ $(function () {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
$.post('/api/report', {id: songId, msg: message, csrfmiddlewaretoken: csrf_token}, function (result) {
|
$.post('/api/report', {id: songId, msg: message, csrfmiddlewaretoken: csrf_token}, function (result) {
|
||||||
console.log(result);
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
createAlert('success', 'Thanks for your song report!');
|
createAlert('success', 'Thanks for your song report!');
|
||||||
}
|
}
|
||||||
@ -209,6 +208,7 @@ function renderQueue(playNextAt, now)
|
|||||||
} else {
|
} else {
|
||||||
var requestNext = !((queue[id+1].requested_by === 'Marietje') && (requestedBy !== 'Marietje'))
|
var requestNext = !((queue[id+1].requested_by === 'Marietje') && (requestedBy !== 'Marietje'))
|
||||||
}
|
}
|
||||||
|
|
||||||
//checks if id is the first item and returns false if the previous song is not Marietje, while the current song is.
|
//checks if id is the first item and returns false if the previous song is not Marietje, while the current song is.
|
||||||
if(id === 0){
|
if(id === 0){
|
||||||
var requestPrev = false
|
var requestPrev = false
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>User</th>
|
<th>User</th>
|
||||||
<th># Songs</th>
|
<th style="text-align: right;"># Songs</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -34,7 +34,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{{ forloop.counter }}</th>
|
<th>{{ forloop.counter }}</th>
|
||||||
<td>{{ stat.user__name }}</td>
|
<td>{{ stat.user__name }}</td>
|
||||||
<td>{{ stat.total }} ({% widthratio stat.total stats.total_uploads 100 %}%)</td>
|
<td style="text-align: right;">{{ stat.total }}</td>
|
||||||
|
<td>({% widthratio stat.total stats.total_uploads 100 %}%)</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -51,7 +52,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>User</th>
|
<th>User</th>
|
||||||
<th># Requests</th>
|
<th style="text-align: right;"># Requests</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -59,7 +60,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{{ forloop.counter }}</th>
|
<th>{{ forloop.counter }}</th>
|
||||||
<td>{{ stat.user__name }}</td>
|
<td>{{ stat.user__name }}</td>
|
||||||
<td>{{ stat.total }} ({% widthratio stat.total stats.total_requests 100 %}%)</td>
|
<td style="text-align: right;">{{ stat.total }}</td>
|
||||||
|
<td>({% widthratio stat.total stats.total_requests 100 %}%)</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -105,7 +107,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>User</th>
|
<th>User</th>
|
||||||
<th># Unique</th>
|
<th style="text-align: right;"># Unique</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -113,7 +115,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{{ forloop.counter }}</th>
|
<th>{{ forloop.counter }}</th>
|
||||||
<td>{{ stat.user__name }}</td>
|
<td>{{ stat.user__name }}</td>
|
||||||
<td>{{ stat.unique_requests }} ({% widthratio stat.unique_requests stat.total_requests 100 %}%)</td>
|
<td style="text-align: right;">{{ stat.unique_requests }}</td>
|
||||||
|
<td>({% widthratio stat.unique_requests stat.total_requests 100 %}%)</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -156,7 +159,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>User</th>
|
<th>User</th>
|
||||||
<th># Others</th>
|
<th style="text-align: right;"># Others</th>
|
||||||
<th># Own</th>
|
<th># Own</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -165,7 +168,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{{ forloop.counter }}</th>
|
<th>{{ forloop.counter }}</th>
|
||||||
<td>{{ stat.name }}</td>
|
<td>{{ stat.name }}</td>
|
||||||
<td>{{ stat.total }}</td>
|
<td style="text-align: right;">{{ stat.total }}</td>
|
||||||
<td>{{ stat.own_total}}</td>
|
<td>{{ stat.own_total}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@ -41,7 +41,7 @@
|
|||||||
<th>{{ forloop.counter }}</th>
|
<th>{{ forloop.counter }}</th>
|
||||||
<td>{{ stat.song__artist }}</td>
|
<td>{{ stat.song__artist }}</td>
|
||||||
<td>{{ stat.song__title }}</td>
|
<td>{{ stat.song__title }}</td>
|
||||||
<td>{{ stat.total }}</td>
|
<td style="text-align: middle;">{{ stat.total }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -64,7 +64,7 @@
|
|||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>Artist</th>
|
<th>Artist</th>
|
||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
<th>Others</th>
|
<th style="text-align: right;">Others</th>
|
||||||
<th>You</th>
|
<th>You</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -74,7 +74,7 @@
|
|||||||
<th>{{ forloop.counter }}</th>
|
<th>{{ forloop.counter }}</th>
|
||||||
<td>{{ stat.song__artist }}</td>
|
<td>{{ stat.song__artist }}</td>
|
||||||
<td>{{ stat.song__title }}</td>
|
<td>{{ stat.song__title }}</td>
|
||||||
<td>{{ stat.total }}</td>
|
<td style="text-align: right;">{{ stat.total }}</td>
|
||||||
<td>{{ stat.user_total }}</td>
|
<td>{{ stat.user_total }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -91,7 +91,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>Uploader</th>
|
<th>Uploader</th>
|
||||||
<th># Requests</th>
|
<th style="text-align: right;"># Requests</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -99,7 +99,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{{ forloop.counter }}</th>
|
<th>{{ forloop.counter }}</th>
|
||||||
<td>{{ stat.song__user__name }}</td>
|
<td>{{ stat.song__user__name }}</td>
|
||||||
<td>{{ stat.total }} ({% widthratio stat.total stats.total_requests 100 %}%)</td>
|
<td style="text-align: right;">{{ stat.total }}</td>
|
||||||
|
<td>({% widthratio stat.total stats.total_requests 100 %}%)</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -127,7 +127,7 @@ def compute_stats():
|
|||||||
total_time_overall = sum(x['avg_dur'] for x in list(stats['time_requested']))
|
total_time_overall = sum(x['avg_dur'] for x in list(stats['time_requested']))
|
||||||
total_average = total_time_overall / len(stats['time_requested'])
|
total_average = total_time_overall / len(stats['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(
|
total_average = '{:.0f} minutes and {:.0f} seconds'.format(
|
||||||
avg_dur_min, avg_dur_sec)
|
avg_dur_min, avg_dur_sec)
|
||||||
|
|
||||||
requests_uploader = PlaylistSong.objects.filter(state=2).exclude(
|
requests_uploader = PlaylistSong.objects.filter(state=2).exclude(
|
||||||
@ -138,7 +138,7 @@ def compute_stats():
|
|||||||
|
|
||||||
most_requested_uploaders = []
|
most_requested_uploaders = []
|
||||||
best_uploaders_list(list(requests_uploader), most_requested_uploaders)
|
best_uploaders_list(list(requests_uploader), most_requested_uploaders)
|
||||||
|
most_requested_uploaders = sorted(most_requested_uploaders, key=lambda x: x['total'], reverse=True)[:settings.STATS_TOP_COUNT]
|
||||||
for time in list(stats['time_requested']):
|
for time in list(stats['time_requested']):
|
||||||
# converts total time and average time in respectively days and minutes, seconds
|
# converts total time and average time in respectively days and minutes, seconds
|
||||||
time['duration'] = str(round(time['total'] / 86400, 2)) + ' days'
|
time['duration'] = str(round(time['total'] / 86400, 2)) + ' days'
|
||||||
@ -150,13 +150,13 @@ def compute_stats():
|
|||||||
# Convert requested time to days
|
# Convert requested time to days
|
||||||
time_requested = list(stats['time_requested'])
|
time_requested = list(stats['time_requested'])
|
||||||
for tr in time_requested:
|
for tr in time_requested:
|
||||||
tr['duration'] = str(round(tr['total'] / 86400, 2)) + ' days'
|
tr['duration'] = "{:5.2f} days".format(tr['total'] / 86400)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'last_updated': last_updated,
|
'last_updated': last_updated,
|
||||||
'total_uploads': stats['total_uploads'],
|
'total_uploads': "{0:,.0f}".format(stats['total_uploads']),
|
||||||
'upload_stats': list(stats['upload_stats']),
|
'upload_stats': list(stats['upload_stats']),
|
||||||
'total_requests': stats['total_requests'],
|
'total_requests': "{0:,.0f}".format(stats['total_requests']),
|
||||||
'request_stats': list(stats['request_stats']),
|
'request_stats': list(stats['request_stats']),
|
||||||
'unique_request_stats': list(stats['unique_request_stats']),
|
'unique_request_stats': list(stats['unique_request_stats']),
|
||||||
'total_unique_requests': stats['total_unique_requests'],
|
'total_unique_requests': stats['total_unique_requests'],
|
||||||
@ -207,7 +207,7 @@ def user_stats(request):
|
|||||||
total=Count('id', filter=~Q(user__id=request)),
|
total=Count('id', filter=~Q(user__id=request)),
|
||||||
user_total=Count('id', filter=Q(user__id=request))).order_by(
|
user_total=Count('id', filter=Q(user__id=request))).order_by(
|
||||||
'-total', 'song__artist',
|
'-total', 'song__artist',
|
||||||
'song__title')[:settings.STATS_TOP_COUNT]
|
'song__title')
|
||||||
|
|
||||||
most_played = list(most_played_uploads)
|
most_played = list(most_played_uploads)
|
||||||
total_played_uploads = 0
|
total_played_uploads = 0
|
||||||
@ -215,7 +215,8 @@ def user_stats(request):
|
|||||||
for x in most_played:
|
for x in most_played:
|
||||||
total_played_uploads += x['total']
|
total_played_uploads += x['total']
|
||||||
total_played_user_uploads += x['user_total']
|
total_played_user_uploads += x['user_total']
|
||||||
|
most_played_uploads_list = sorted(most_played_uploads, key=lambda x: (x['song__artist'], x['song__title']))
|
||||||
|
most_played_uploads_list = sorted(most_played_uploads_list, key=lambda x: x["total"], reverse=True)[:settings.STATS_TOP_COUNT]
|
||||||
return {
|
return {
|
||||||
'last_updated': last_updated,
|
'last_updated': last_updated,
|
||||||
'total_uploads': total_uploads,
|
'total_uploads': total_uploads,
|
||||||
@ -223,7 +224,7 @@ def user_stats(request):
|
|||||||
'unique_requests': unique_requests,
|
'unique_requests': unique_requests,
|
||||||
'most_played_songs': list(most_played_songs),
|
'most_played_songs': list(most_played_songs),
|
||||||
'most_played_uploaders': list(most_played_uploaders),
|
'most_played_uploaders': list(most_played_uploaders),
|
||||||
'most_played_uploads': list(most_played_uploads),
|
'most_played_uploads': most_played_uploads_list,
|
||||||
'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