Fix month display showing "invalid date" on totals graph.

Make duration on home stats human readable.
This commit is contained in:
Tim 2015-08-18 22:59:24 +02:00
parent 7e8a427107
commit 2536fdf17b
2 changed files with 25 additions and 17 deletions

View file

@ -458,12 +458,8 @@
data: { y_axis: yaxis },
dataType: "json",
success: function(data) {
var dateArray = [];
for (var i = 0; i < data.categories.length; i++) {
dateArray.push(moment(data.categories[i], 'YYYY-MM').format('MMM YYYY'));
}
hc_plays_by_month_options.yAxis.min = 0;
hc_plays_by_month_options.xAxis.categories = dateArray;
hc_plays_by_month_options.xAxis.categories = data.categories;
hc_plays_by_month_options.series = data.series;
var hc_plays_by_month = new Highcharts.Chart(hc_plays_by_month_options);
}

View file

@ -41,6 +41,22 @@ platform_type Returns the platform name for the associated stat.
DOCUMENTATION :: END
</%doc>
<%!
from plexpy import helpers
# Human readable duration
def hd(minutes):
if int(minutes) > 60:
hours = int(helpers.cast_to_float(minutes) / 60)
minutes = int(helpers.cast_to_float(minutes) % hours)
if minutes > 0:
return "<h3>" + str(hours) + "</h3><p>hrs</p><h3>" + str(minutes) + "</h3><p>mins</p>"
else:
return "<h3>" + str(hours) + "</h3><p>hrs</p>"
else:
return "<h3>" + minutes + "</h3><p>mins</p>"
%>
% if data:
% if data[0]['rows'] or data[2]['rows']:
<ul class="list-unstyled">
@ -69,9 +85,8 @@ DOCUMENTATION :: END
<h3>${a['rows'][0]['total_plays']}</h3>
<p> plays</p>
% else:
<h3>${a['rows'][0]['total_duration']}</h3>
<p> mins</p>
% endif
${a['rows'][0]['total_duration'] | hd}
% endif
</div>
</li>
</div>
@ -124,9 +139,8 @@ DOCUMENTATION :: END
<h3>${a['rows'][0]['total_plays']}</h3>
<p> plays</p>
% else:
<h3>${a['rows'][0]['total_duration']}</h3>
<p> mins</p>
% endif
${a['rows'][0]['total_duration'] | hd}
% endif
</div>
</li>
</div>
@ -190,9 +204,8 @@ DOCUMENTATION :: END
<h3>${a['rows'][0]['total_plays']}</h3>
<p> plays</p>
% else:
<h3>${a['rows'][0]['total_duration']}</h3>
<p> mins</p>
% endif
${a['rows'][0]['total_duration'] | hd}
% endif
</div>
</li>
</div>
@ -211,9 +224,8 @@ DOCUMENTATION :: END
<h3>${a['rows'][0]['total_plays']}</h3>
<p> plays</p>
% else:
<h3>${a['rows'][0]['total_duration']}</h3>
<p> mins</p>
% endif
${a['rows'][0]['total_duration'] | hd}
% endif
</div>
</li>
</div>