Fix for empty most concurrent stat

This commit is contained in:
Jonathan Wong 2016-01-12 22:06:21 -08:00
parent 3d6f89d309
commit 78ee646558
2 changed files with 13 additions and 5 deletions

View file

@ -72,6 +72,7 @@ DOCUMENTATION :: END
% if data: % if data:
% if data[0]['stat_id']: % if data[0]['stat_id']:
<ul class="list-unstyled"> <ul class="list-unstyled">
% if any(top_stat['rows'] for top_stat in data):
% for top_stat in data: % for top_stat in data:
% if top_stat['stat_id'] == 'top_tv' and top_stat['rows']: % if top_stat['stat_id'] == 'top_tv' and top_stat['rows']:
<div class="home-platforms-instance"> <div class="home-platforms-instance">
@ -852,6 +853,9 @@ DOCUMENTATION :: END
</div> </div>
% endif % endif
% endfor % endfor
% else:
<div class="text-muted">No stats to show for the selected period.</div><br>
% endif
</ul> </ul>
<script> <script>
var topZIndex = 2; var topZIndex = 2;
@ -867,7 +871,7 @@ DOCUMENTATION :: END
}); });
</script> </script>
% else: % else:
<div class="text-muted">No stats for selected period.</div><br> <div class="text-muted">No stats to show for the selected period.</div><br>
% endif % endif
% else: % else:
<div class="text-muted">Unable to retrieve data from database. Please check your <a href="settings">settings</a>. <div class="text-muted">Unable to retrieve data from database. Please check your <a href="settings">settings</a>.

View file

@ -619,6 +619,7 @@ class DataFactory(object):
title = 'Concurrent Streams' title = 'Concurrent Streams'
query = base_query query = base_query
result = monitor_db.select(query) result = monitor_db.select(query)
if result:
most_concurrent.append(calc_most_concurrent(title, result)) most_concurrent.append(calc_most_concurrent(title, result))
title = 'Concurrent Transcodes' title = 'Concurrent Transcodes'
@ -626,6 +627,7 @@ class DataFactory(object):
+ 'AND (session_history_media_info.video_decision = "transcode" ' \ + 'AND (session_history_media_info.video_decision = "transcode" ' \
'OR session_history_media_info.audio_decision = "transcode") ' 'OR session_history_media_info.audio_decision = "transcode") '
result = monitor_db.select(query) result = monitor_db.select(query)
if result:
most_concurrent.append(calc_most_concurrent(title, result)) most_concurrent.append(calc_most_concurrent(title, result))
title = 'Concurrent Direct Streams' title = 'Concurrent Direct Streams'
@ -633,6 +635,7 @@ class DataFactory(object):
+ 'AND (session_history_media_info.video_decision != "transcode" ' \ + 'AND (session_history_media_info.video_decision != "transcode" ' \
'AND session_history_media_info.audio_decision = "copy") ' 'AND session_history_media_info.audio_decision = "copy") '
result = monitor_db.select(query) result = monitor_db.select(query)
if result:
most_concurrent.append(calc_most_concurrent(title, result)) most_concurrent.append(calc_most_concurrent(title, result))
title = 'Concurrent Direct Plays' title = 'Concurrent Direct Plays'
@ -640,6 +643,7 @@ class DataFactory(object):
+ 'AND (session_history_media_info.video_decision = "direct play" ' \ + 'AND (session_history_media_info.video_decision = "direct play" ' \
'OR session_history_media_info.audio_decision = "direct play") ' 'OR session_history_media_info.audio_decision = "direct play") '
result = monitor_db.select(query) result = monitor_db.select(query)
if result:
most_concurrent.append(calc_most_concurrent(title, result)) most_concurrent.append(calc_most_concurrent(title, result))
except: except:
logger.warn("Unable to execute database query for get_home_stats: most_concurrent.") logger.warn("Unable to execute database query for get_home_stats: most_concurrent.")