From 8492924ad99e24c96ace9f09c6f1b3200285c2d6 Mon Sep 17 00:00:00 2001 From: Will Foster Date: Fri, 27 Sep 2024 17:43:24 +0100 Subject: [PATCH] fix: heatmap fails when no hosts defined. * we should just display the page with no data instead of app error when during new installs someone runs --regen-heatmap. Change-Id: I61116b1cc7e27617bab7e59500eb3d8097ab1a1e --- src/quads/tools/simple_table_generator.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/quads/tools/simple_table_generator.py b/src/quads/tools/simple_table_generator.py index 11f12ad8..085f4129 100755 --- a/src/quads/tools/simple_table_generator.py +++ b/src/quads/tools/simple_table_generator.py @@ -167,8 +167,12 @@ async def generator(self, _host_file, _days, _month, _year, _gentime): total_hosts = len(hosts) total_use = len(total_current_schedules) - utilization = 100 - (non_allocated_count * 100 // (_days * total_hosts)) - utilization_daily = total_use * 100 // total_hosts + if int(total_hosts) == 0: + utilization_daily = 0 + utilization = 0 + else: + utilization = 100 - (non_allocated_count * 100 // (_days * total_hosts)) + utilization_daily = total_use * 100 // total_hosts with open(os.path.join(Config.TEMPLATES_PATH, "simple_table_emoji")) as _file: template = Template(_file.read()) content = template.render(