From 78ee64655870c8f839d6accfa7e23e9caff63079 Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Tue, 12 Jan 2016 22:06:21 -0800 Subject: [PATCH] Fix for empty most concurrent stat --- data/interfaces/default/home_stats.html | 6 +++++- plexpy/datafactory.py | 12 ++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/data/interfaces/default/home_stats.html b/data/interfaces/default/home_stats.html index 6f5884e2..fa4ac42d 100644 --- a/data/interfaces/default/home_stats.html +++ b/data/interfaces/default/home_stats.html @@ -72,6 +72,7 @@ DOCUMENTATION :: END % if data: % if data[0]['stat_id']: % else: -
No stats for selected period.

+
No stats to show for the selected period.

% endif % else:
Unable to retrieve data from database. Please check your settings. diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 1ee80435..a9fdf29e 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -619,28 +619,32 @@ class DataFactory(object): title = 'Concurrent Streams' query = base_query result = monitor_db.select(query) - most_concurrent.append(calc_most_concurrent(title, result)) + if result: + most_concurrent.append(calc_most_concurrent(title, result)) title = 'Concurrent Transcodes' query = base_query \ + 'AND (session_history_media_info.video_decision = "transcode" ' \ 'OR session_history_media_info.audio_decision = "transcode") ' result = monitor_db.select(query) - most_concurrent.append(calc_most_concurrent(title, result)) + if result: + most_concurrent.append(calc_most_concurrent(title, result)) title = 'Concurrent Direct Streams' query = base_query \ + 'AND (session_history_media_info.video_decision != "transcode" ' \ 'AND session_history_media_info.audio_decision = "copy") ' result = monitor_db.select(query) - most_concurrent.append(calc_most_concurrent(title, result)) + if result: + most_concurrent.append(calc_most_concurrent(title, result)) title = 'Concurrent Direct Plays' query = base_query \ + 'AND (session_history_media_info.video_decision = "direct play" ' \ 'OR session_history_media_info.audio_decision = "direct play") ' result = monitor_db.select(query) - most_concurrent.append(calc_most_concurrent(title, result)) + if result: + most_concurrent.append(calc_most_concurrent(title, result)) except: logger.warn("Unable to execute database query for get_home_stats: most_concurrent.") return None