From c258e5f89f01d2d1f1e2eab0e4b62dca0bca3fc6 Mon Sep 17 00:00:00 2001 From: user Date: Tue, 26 Mar 2024 22:06:53 +0100 Subject: chart summarize single attempts for load time and visual noise reduction --- src/ssh_node5_net.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') 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' -- cgit v1.2.3