diff --git a/marietje/marietje/static/js/queue.js b/marietje/marietje/static/js/queue.js
index cfcdcb2..7fc0758 100644
--- a/marietje/marietje/static/js/queue.js
+++ b/marietje/marietje/static/js/queue.js
@@ -56,7 +56,6 @@ $(function () {
return false
}
$.post('/api/report', {id: songId, msg: message, csrfmiddlewaretoken: csrf_token}, function (result) {
- console.log(result);
if (result.success) {
createAlert('success', 'Thanks for your song report!');
}
@@ -209,6 +208,7 @@ function renderQueue(playNextAt, now)
} else {
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.
if(id === 0){
var requestPrev = false
diff --git a/marietje/stats/templates/stats/stats.html b/marietje/stats/templates/stats/stats.html
index f6ed1f6..d388541 100644
--- a/marietje/stats/templates/stats/stats.html
+++ b/marietje/stats/templates/stats/stats.html
@@ -26,7 +26,7 @@
| # |
User |
- # Songs |
+ # Songs |
@@ -34,7 +34,8 @@
| {{ forloop.counter }} |
{{ stat.user__name }} |
- {{ stat.total }} ({% widthratio stat.total stats.total_uploads 100 %}%) |
+ {{ stat.total }} |
+ ({% widthratio stat.total stats.total_uploads 100 %}%) |
{% endfor %}
@@ -51,7 +52,7 @@
| # |
User |
- # Requests |
+ # Requests |
@@ -59,7 +60,8 @@
| {{ forloop.counter }} |
{{ stat.user__name }} |
- {{ stat.total }} ({% widthratio stat.total stats.total_requests 100 %}%) |
+ {{ stat.total }} |
+ ({% widthratio stat.total stats.total_requests 100 %}%) |
{% endfor %}
@@ -105,7 +107,7 @@
| # |
User |
- # Unique |
+ # Unique |
@@ -113,7 +115,8 @@
| {{ forloop.counter }} |
{{ stat.user__name }} |
- {{ stat.unique_requests }} ({% widthratio stat.unique_requests stat.total_requests 100 %}%) |
+ {{ stat.unique_requests }} |
+ ({% widthratio stat.unique_requests stat.total_requests 100 %}%) |
{% endfor %}
@@ -156,7 +159,7 @@
| # |
User |
- # Others |
+ # Others |
# Own |
@@ -165,7 +168,7 @@
| {{ forloop.counter }} |
{{ stat.name }} |
- {{ stat.total }} |
+ {{ stat.total }} |
{{ stat.own_total}} |
{% endfor %}
diff --git a/marietje/stats/templates/stats/user.html b/marietje/stats/templates/stats/user.html
index 0b373a5..d1bdcb3 100644
--- a/marietje/stats/templates/stats/user.html
+++ b/marietje/stats/templates/stats/user.html
@@ -41,7 +41,7 @@
{{ forloop.counter }} |
{{ stat.song__artist }} |
{{ stat.song__title }} |
- {{ stat.total }} |
+ {{ stat.total }} |
{% endfor %}
@@ -64,7 +64,7 @@
# |
Artist |
Title |
- Others |
+ Others |
You |
@@ -74,7 +74,7 @@
{{ forloop.counter }} |
{{ stat.song__artist }} |
{{ stat.song__title }} |
- {{ stat.total }} |
+ {{ stat.total }} |
{{ stat.user_total }} |
{% endfor %}
@@ -91,7 +91,7 @@
| # |
Uploader |
- # Requests |
+ # Requests |
@@ -99,7 +99,8 @@
| {{ forloop.counter }} |
{{ stat.song__user__name }} |
- {{ stat.total }} ({% widthratio stat.total stats.total_requests 100 %}%) |
+ {{ stat.total }} |
+ ({% widthratio stat.total stats.total_requests 100 %}%) |
{% endfor %}
diff --git a/marietje/stats/utils.py b/marietje/stats/utils.py
index 5555ea1..519c0d9 100644
--- a/marietje/stats/utils.py
+++ b/marietje/stats/utils.py
@@ -127,7 +127,7 @@ def compute_stats():
total_time_overall = sum(x['avg_dur'] for x in list(stats['time_requested']))
total_average = total_time_overall / len(stats['time_requested'])
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)
requests_uploader = PlaylistSong.objects.filter(state=2).exclude(
@@ -138,7 +138,7 @@ def compute_stats():
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']):
# converts total time and average time in respectively days and minutes, seconds
time['duration'] = str(round(time['total'] / 86400, 2)) + ' days'
@@ -150,13 +150,13 @@ def compute_stats():
# Convert requested time to days
time_requested = list(stats['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 {
'last_updated': last_updated,
- 'total_uploads': stats['total_uploads'],
+ 'total_uploads': "{0:,.0f}".format(stats['total_uploads']),
'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']),
'unique_request_stats': list(stats['unique_request_stats']),
'total_unique_requests': stats['total_unique_requests'],
@@ -207,7 +207,7 @@ def user_stats(request):
total=Count('id', filter=~Q(user__id=request)),
user_total=Count('id', filter=Q(user__id=request))).order_by(
'-total', 'song__artist',
- 'song__title')[:settings.STATS_TOP_COUNT]
+ 'song__title')
most_played = list(most_played_uploads)
total_played_uploads = 0
@@ -215,7 +215,8 @@ def user_stats(request):
for x in most_played:
total_played_uploads += x['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 {
'last_updated': last_updated,
'total_uploads': total_uploads,
@@ -223,7 +224,7 @@ def user_stats(request):
'unique_requests': unique_requests,
'most_played_songs': list(most_played_songs),
'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,
'total_played_uploads': total_played_uploads,
'total_played_user_uploads': total_played_user_uploads,