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

@ -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>