You've already forked wakapi-readme-stats
fix div zero
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user