summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ssh_node5_net.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/ssh_node5_net.py b/src/ssh_node5_net.py
index 43b9dd9..5acb229 100644
--- a/src/ssh_node5_net.py
+++ b/src/ssh_node5_net.py
@@ -57,18 +57,22 @@ def format_time(input: datetime.datetime) -> str:
histogram_labels = [format_time(a['date']) for a in histogram]
'''
-
+min_value = 1
def get_chart():
histogram = db_handler.get_histogram_detailed()
all_dates = sorted(list({d['date'] for d in histogram}))
by_ip = {}
for data in histogram:
- if data['ip'] not in by_ip:
- by_ip[data['ip']] = [0] * len(all_dates)
- by_ip[data['ip']][all_dates.index(data['date'])] = data['total_count']
+ if data['total_count'] <= min_value:
+ ip = f'Misc. (<= {min_value})'
+ else:
+ ip = str(data['ip'])
+ if ip not in by_ip:
+ by_ip[ip] = [0] * len(all_dates)
+ by_ip[ip][all_dates.index(data['date'])] += data['total_count']
histogram_chartjs = json.dumps([{
- 'label': str(ip),
+ 'label': ip,
'data': data,
'backgroundColor': f'hsl({random.randrange(0, 360)}, 50%, 50%)',
'fill': 'start'