Fix history Live TV filter when combined with other filters

This commit is contained in:
JonnyWong16 2021-10-19 17:54:28 -07:00
parent d041c8a03b
commit b9d4f57a4e
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 9 additions and 13 deletions

View file

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# This file is part of Tautulli. # This file is part of Tautulli.
# #
@ -102,6 +102,8 @@ class DataFactory(object):
'ip_address', 'ip_address',
'machine_id', 'machine_id',
'session_history.media_type', 'session_history.media_type',
'(CASE WHEN session_history_metadata.live = 1 THEN "live" ELSE session_history.media_type END) \
AS media_type_live',
'session_history_metadata.rating_key', 'session_history_metadata.rating_key',
'session_history_metadata.parent_rating_key', 'session_history_metadata.parent_rating_key',
'session_history_metadata.grandparent_rating_key', 'session_history_metadata.grandparent_rating_key',
@ -155,6 +157,7 @@ class DataFactory(object):
'ip_address', 'ip_address',
'machine_id', 'machine_id',
'media_type', 'media_type',
'(CASE WHEN live = 1 THEN "live" ELSE media_type END) AS media_type_live',
'rating_key', 'rating_key',
'parent_rating_key', 'parent_rating_key',
'grandparent_rating_key', 'grandparent_rating_key',
@ -1267,7 +1270,9 @@ class DataFactory(object):
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) - ' \
'SUM(CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) AS total_duration ' \ 'SUM(CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) AS total_duration, ' \
'(CASE WHEN session_history_metadata.live = 1 THEN "live" ELSE session_history.media_type END) ' \
'AS media_type_live ' \
'FROM session_history ' \ 'FROM session_history ' \
'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 ' \

View file

@ -2004,17 +2004,8 @@ class WebInterface(object):
custom_where.append(['session_history.section_id', section_id]) custom_where.append(['session_history.section_id', section_id])
if 'media_type' in kwargs: if 'media_type' in kwargs:
media_type = helpers.split_strip(kwargs.get('media_type', '')) media_type = helpers.split_strip(kwargs.get('media_type', ''))
if media_type and 'all' not in media_type: if media_type:
if 'live' in media_type: custom_where.append(['media_type_live', media_type])
media_type.remove('live')
if len(media_type):
custom_where.append(['session_history_metadata.live OR', '1'])
else:
custom_where.append(['session_history_metadata.live', '1'])
else:
custom_where.append(['session_history_metadata.live', '0'])
if media_type:
custom_where.append(['session_history.media_type', media_type])
if 'transcode_decision' in kwargs: if 'transcode_decision' in kwargs:
transcode_decision = helpers.split_strip(kwargs.get('transcode_decision', '')) transcode_decision = helpers.split_strip(kwargs.get('transcode_decision', ''))
if transcode_decision and 'all' not in transcode_decision: if transcode_decision and 'all' not in transcode_decision: