mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 04:49:36 -07:00
Use datatables helper for total_duration query
This commit is contained in:
parent
9b4f4b8ae4
commit
5197418cb8
1 changed files with 2 additions and 6 deletions
|
@ -1264,11 +1264,7 @@ class DataFactory(object):
|
||||||
def get_total_duration(self, custom_where=None):
|
def get_total_duration(self, custom_where=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
# Split up custom wheres
|
where, args = datatables.build_custom_where(custom_where=custom_where)
|
||||||
if custom_where:
|
|
||||||
where = 'WHERE ' + ' AND '.join([w[0] + ' = "' + w[1] + '"' for w in custom_where])
|
|
||||||
else:
|
|
||||||
where = ''
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
query = 'SELECT SUM(CASE WHEN stopped > 0 THEN (stopped - started) ELSE 0 END) - ' \
|
query = 'SELECT SUM(CASE WHEN stopped > 0 THEN (stopped - started) ELSE 0 END) - ' \
|
||||||
|
@ -1277,7 +1273,7 @@ class DataFactory(object):
|
||||||
'JOIN session_history_metadata ON session_history_metadata.id = session_history.id ' \
|
'JOIN session_history_metadata ON session_history_metadata.id = session_history.id ' \
|
||||||
'JOIN session_history_media_info ON session_history_media_info.id = session_history.id ' \
|
'JOIN session_history_media_info ON session_history_media_info.id = session_history.id ' \
|
||||||
'%s ' % where
|
'%s ' % where
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query, args=args)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn("Tautulli DataFactory :: Unable to execute database query for get_total_duration: %s." % e)
|
logger.warn("Tautulli DataFactory :: Unable to execute database query for get_total_duration: %s." % e)
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue