mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Fix most concurrent stat for empty database
This commit is contained in:
parent
45c2f50018
commit
2942640eb9
1 changed files with 10 additions and 8 deletions
|
@ -587,23 +587,25 @@ class DataFactory(object):
|
||||||
times = sorted(times, key=lambda k: k['time'])
|
times = sorted(times, key=lambda k: k['time'])
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
last_count = 0
|
||||||
last_start = 0
|
last_start = 0
|
||||||
most_concurrent = {'count': count}
|
most_concurrent = []
|
||||||
|
|
||||||
for d in times:
|
for d in times:
|
||||||
if d['count'] == 1:
|
if d['count'] == 1:
|
||||||
count += d['count']
|
count += d['count']
|
||||||
if count >= most_concurrent['count']:
|
if count >= last_count:
|
||||||
last_start = d['time']
|
last_start = d['time']
|
||||||
else:
|
else:
|
||||||
if count >= most_concurrent['count']:
|
if count >= last_count:
|
||||||
most_concurrent = {'count': count,
|
last_count = count
|
||||||
'started': last_start[:-1],
|
most_concurrent = [{'count': count,
|
||||||
'stopped': d['time'][:-1]}
|
'started': last_start[:-1],
|
||||||
|
'stopped': d['time'][:-1]}]
|
||||||
count += d['count']
|
count += d['count']
|
||||||
|
|
||||||
home_stats.append({'stat_id': stat,
|
home_stats.append({'stat_id': stat,
|
||||||
'rows': [most_concurrent]})
|
'rows': most_concurrent})
|
||||||
|
|
||||||
return home_stats
|
return home_stats
|
||||||
|
|
||||||
|
@ -1087,4 +1089,4 @@ class DataFactory(object):
|
||||||
for item in result:
|
for item in result:
|
||||||
total_duration = item['total_duration']
|
total_duration = item['total_duration']
|
||||||
|
|
||||||
return total_duration
|
return total_duration
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue