mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Change default sig of human duration function
This commit is contained in:
parent
4d37f2bab2
commit
881f37f731
5 changed files with 18 additions and 12 deletions
|
@ -373,8 +373,7 @@ DOCUMENTATION :: END
|
||||||
</div>
|
</div>
|
||||||
<div class="summary-content-details-tag">
|
<div class="summary-content-details-tag">
|
||||||
% if data['duration']:
|
% if data['duration']:
|
||||||
<% sig = 'dhms' if cast_to_int(data['duration']) < 300000 else 'dhm' %>
|
Runtime <strong> <span id="runtime">${data['duration']}</span></strong>
|
||||||
Runtime <strong> <span id="runtime" data-sig="${sig}">${data['duration']}</span></strong>
|
|
||||||
% endif
|
% endif
|
||||||
</div>
|
</div>
|
||||||
<div class="summary-content-details-tag">
|
<div class="summary-content-details-tag">
|
||||||
|
@ -933,7 +932,7 @@ DOCUMENTATION :: END
|
||||||
var airdate = $("#airdate")
|
var airdate = $("#airdate")
|
||||||
var runtime = $("#runtime")
|
var runtime = $("#runtime")
|
||||||
airdate.html(moment(airdate.text()).format('MMM DD, YYYY'));
|
airdate.html(moment(airdate.text()).format('MMM DD, YYYY'));
|
||||||
runtime.html(humanDuration(runtime.text(), runtime.data('sig')));
|
runtime.html(humanDuration(runtime.text()));
|
||||||
|
|
||||||
$('div.art-face').animate({ opacity: 0.2 }, { duration: 1000 });
|
$('div.art-face').animate({ opacity: 0.2 }, { duration: 1000 });
|
||||||
$('#channel-icon').popover({
|
$('#channel-icon').popover({
|
||||||
|
|
|
@ -354,7 +354,7 @@ function millisecondsToMinutes(ms, roundToMinute) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function humanDuration(ms, sig='dhms', units='ms') {
|
function humanDuration(ms, sig='dhm', units='ms', return_seconds=300000) {
|
||||||
var factors = {
|
var factors = {
|
||||||
d: 86400000,
|
d: 86400000,
|
||||||
h: 3600000,
|
h: 3600000,
|
||||||
|
@ -367,6 +367,10 @@ function humanDuration(ms, sig='dhms', units='ms') {
|
||||||
var d, h, m, s;
|
var d, h, m, s;
|
||||||
|
|
||||||
if (ms > 0) {
|
if (ms > 0) {
|
||||||
|
if (return_seconds && ms < return_seconds) {
|
||||||
|
sig = 'dhms'
|
||||||
|
}
|
||||||
|
|
||||||
ms = ms * factors[units];
|
ms = ms * factors[units];
|
||||||
|
|
||||||
h = ms % factors['d'];
|
h = ms % factors['d'];
|
||||||
|
|
|
@ -290,8 +290,8 @@ class DataFactory(object):
|
||||||
'recordsTotal': query['totalCount'],
|
'recordsTotal': query['totalCount'],
|
||||||
'data': session.friendly_name_to_username(rows),
|
'data': session.friendly_name_to_username(rows),
|
||||||
'draw': query['draw'],
|
'draw': query['draw'],
|
||||||
'filter_duration': helpers.human_duration(filter_duration, sig='dhm', units='s'),
|
'filter_duration': helpers.human_duration(filter_duration, units='s'),
|
||||||
'total_duration': helpers.human_duration(total_duration, sig='dhm', units='s')
|
'total_duration': helpers.human_duration(total_duration, units='s')
|
||||||
}
|
}
|
||||||
|
|
||||||
return dict
|
return dict
|
||||||
|
|
|
@ -166,7 +166,7 @@ class Export(object):
|
||||||
'tag': None
|
'tag': None
|
||||||
},
|
},
|
||||||
'duration': None,
|
'duration': None,
|
||||||
'durationHuman': lambda o: helpers.human_duration(getattr(o, 'duration', 0), sig='dhm'),
|
'durationHuman': lambda o: helpers.human_duration(getattr(o, 'duration', 0)),
|
||||||
'fields': {
|
'fields': {
|
||||||
'name': None,
|
'name': None,
|
||||||
'locked': None
|
'locked': None
|
||||||
|
@ -362,7 +362,7 @@ class Export(object):
|
||||||
},
|
},
|
||||||
'contentRating': None,
|
'contentRating': None,
|
||||||
'duration': None,
|
'duration': None,
|
||||||
'durationHuman': lambda o: helpers.human_duration(getattr(o, 'duration', 0), sig='dhm'),
|
'durationHuman': lambda o: helpers.human_duration(getattr(o, 'duration', 0)),
|
||||||
'fields': {
|
'fields': {
|
||||||
'name': None,
|
'name': None,
|
||||||
'locked': None
|
'locked': None
|
||||||
|
@ -461,7 +461,7 @@ class Export(object):
|
||||||
'tag': None
|
'tag': None
|
||||||
},
|
},
|
||||||
'duration': None,
|
'duration': None,
|
||||||
'durationHuman': lambda o: helpers.human_duration(getattr(o, 'duration', 0), sig='dhm'),
|
'durationHuman': lambda o: helpers.human_duration(getattr(o, 'duration', 0)),
|
||||||
'fields': {
|
'fields': {
|
||||||
'name': None,
|
'name': None,
|
||||||
'locked': None
|
'locked': None
|
||||||
|
@ -750,7 +750,7 @@ class Export(object):
|
||||||
'addedAt': helpers.datetime_to_iso,
|
'addedAt': helpers.datetime_to_iso,
|
||||||
'art': None,
|
'art': None,
|
||||||
'duration': None,
|
'duration': None,
|
||||||
'durationHuman': lambda o: helpers.human_duration(getattr(o, 'duration', 0), sig='dhm'),
|
'durationHuman': lambda o: helpers.human_duration(getattr(o, 'duration', 0)),
|
||||||
'fields': {
|
'fields': {
|
||||||
'name': None,
|
'name': None,
|
||||||
'locked': None
|
'locked': None
|
||||||
|
@ -997,7 +997,7 @@ class Export(object):
|
||||||
'addedAt': helpers.datetime_to_iso,
|
'addedAt': helpers.datetime_to_iso,
|
||||||
'composite': None,
|
'composite': None,
|
||||||
'duration': None,
|
'duration': None,
|
||||||
'durationHuman': lambda o: helpers.human_duration(getattr(o, 'duration', 0), sig='dhm'),
|
'durationHuman': lambda o: helpers.human_duration(getattr(o, 'duration', 0)),
|
||||||
'guid': None,
|
'guid': None,
|
||||||
'key': None,
|
'key': None,
|
||||||
'leafCount': None,
|
'leafCount': None,
|
||||||
|
|
|
@ -251,7 +251,7 @@ def datetime_to_iso(dt, to_date=False):
|
||||||
return dt
|
return dt
|
||||||
|
|
||||||
|
|
||||||
def human_duration(ms, sig='dhms', units='ms'):
|
def human_duration(ms, sig='dhm', units='ms', return_seconds=300000):
|
||||||
factors = {'d': 86400000,
|
factors = {'d': 86400000,
|
||||||
'h': 3600000,
|
'h': 3600000,
|
||||||
'm': 60000,
|
'm': 60000,
|
||||||
|
@ -259,6 +259,9 @@ def human_duration(ms, sig='dhms', units='ms'):
|
||||||
'ms': 1}
|
'ms': 1}
|
||||||
|
|
||||||
if str(ms).isdigit() and ms > 0:
|
if str(ms).isdigit() and ms > 0:
|
||||||
|
if return_seconds and ms < return_seconds:
|
||||||
|
sig = 'dhms'
|
||||||
|
|
||||||
ms = ms * factors[units]
|
ms = ms * factors[units]
|
||||||
|
|
||||||
d, h = divmod(ms, factors['d'])
|
d, h = divmod(ms, factors['d'])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue