diff options
| author | user <user@node5.net> | 2024-03-26 22:06:53 +0100 |
|---|---|---|
| committer | user <user@node5.net> | 2024-03-26 22:06:53 +0100 |
| commit | c258e5f89f01d2d1f1e2eab0e4b62dca0bca3fc6 (patch) | |
| tree | 796d589ec4b93d0b8e3c7fbd77141e2803bca6d9 | |
| parent | 57ba2cc237203e85756cecd92202d4785b234850 (diff) | |
chart summarize single attempts for load time and visual noise reduction
| -rw-r--r-- | src/ssh_node5_net.py | 14 |
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' |
