From 95b0de8a4b6b31be5a239584ac95d22523a0131a Mon Sep 17 00:00:00 2001 From: PuQing Date: Wed, 15 Mar 2023 14:40:47 +0800 Subject: [PATCH] fix div zero --- sources/graphics_list_formatter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/graphics_list_formatter.py b/sources/graphics_list_formatter.py index ce1263f..c605067 100644 --- a/sources/graphics_list_formatter.py +++ b/sources/graphics_list_formatter.py @@ -105,14 +105,14 @@ async def make_commit_day_time_list(time_zone: str, repositories: Dict, commit_d dt_names = [f"{DAY_TIME_EMOJI[i]} {FM.t(DAY_TIME_NAMES[i])}" for i in range(len(day_times))] dt_texts = [f"{day_time} commits" for day_time in day_times] - dt_percents = [round((day_time / sum_day) * 100, 2) for day_time in day_times] + dt_percents = [0 if sum_day == 0 else round((day_time / sum_day) * 100, 2) for day_time in day_times] title = FM.t("I am an Early") if sum(day_times[0:2]) >= sum(day_times[2:4]) else FM.t("I am a Night") stats += f"**{title}** \n\n```text\n{make_list(names=dt_names, texts=dt_texts, percents=dt_percents, top_num=7, sort=False)}\n```\n" if EM.SHOW_DAYS_OF_WEEK: wd_names = [FM.t(week_day) for week_day in WEEK_DAY_NAMES] wd_texts = [f"{week_day} commits" for week_day in week_days] - wd_percents = [round((week_day / sum_week) * 100, 2) for week_day in week_days] + wd_percents = [0 if sum_week == 0 else round((week_day / sum_week) * 100, 2) for week_day in week_days] title = FM.t("I am Most Productive on") % wd_names[wd_percents.index(max(wd_percents))] stats += f"📅 **{title}** \n\n```text\n{make_list(names=wd_names, texts=wd_texts, percents=wd_percents, top_num=7, sort=False)}\n```\n"