mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Add most concurrent streams home statistic
This commit is contained in:
parent
6e62ffdd22
commit
9cf6793b24
5 changed files with 64 additions and 1 deletions
|
@ -589,6 +589,38 @@ class DataFactory(object):
|
|||
home_stats.append({'stat_id': stat,
|
||||
'rows': last_watched})
|
||||
|
||||
elif stat == 'most_concurrent':
|
||||
try:
|
||||
query = 'SELECT started, stopped ' \
|
||||
'FROM session_history '
|
||||
result = monitor_db.select(query)
|
||||
except:
|
||||
logger.warn("Unable to execute database query for get_home_stats: most_concurrent.")
|
||||
return None
|
||||
|
||||
times = {}
|
||||
for item in result:
|
||||
times.update({str(item['stopped']) + 'A': -1, str(item['started']) + 'B': 1})
|
||||
|
||||
count = 0
|
||||
last_start = 0
|
||||
most_concurrent = {'count': count}
|
||||
|
||||
for key in sorted(times):
|
||||
if times[key] == 1:
|
||||
count += times[key]
|
||||
if count >= most_concurrent['count']:
|
||||
last_start = key
|
||||
else:
|
||||
if count >= most_concurrent['count']:
|
||||
most_concurrent = {'count': count,
|
||||
'started': last_start[:-1],
|
||||
'stopped': key[:-1]}
|
||||
count += times[key]
|
||||
|
||||
home_stats.append({'stat_id': stat,
|
||||
'rows': [most_concurrent]})
|
||||
|
||||
return home_stats
|
||||
|
||||
def get_stream_details(self, row_id=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue