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

View file

@ -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