You've already forked wakapi-readme-stats
coroutine cancellation added
This commit is contained in:
@@ -34,18 +34,18 @@ def make_graph(percent: float):
|
||||
return f"{done_block * percent_quart}{empty_block * (25 - percent_quart)}"
|
||||
|
||||
|
||||
def make_list(data: Dict = None, names: List[str] = None, texts: List[str] = None, percents: List[float] = None, top_num: int = 5, sort: bool = True) -> str:
|
||||
def make_list(data: List = None, names: List[str] = None, texts: List[str] = None, percents: List[float] = None, top_num: int = 5, sort: bool = True) -> str:
|
||||
"""
|
||||
Make List
|
||||
"""
|
||||
if data is not None:
|
||||
names = [value for key, value in data if key == "name"] if names is None else names
|
||||
texts = [value for key, value in data if key == "text"] if texts is None else texts
|
||||
percents = [value for key, value in data if key == "percent"] if percents is None else percents
|
||||
names = [value for item in data for key, value in item.items() if key == "name"] if names is None else names
|
||||
texts = [value for item in data for key, value in item.items() if key == "text"] if texts is None else texts
|
||||
percents = [value for item in data for key, value in item.items() if key == "percent"] if percents is None else percents
|
||||
|
||||
data = list(zip(names, texts, percents))
|
||||
top_data = sorted(data[:top_num], key=lambda _, __, p: p) if sort else data[:top_num]
|
||||
data_list = [f"{n:25]}{' ' * (25 - len(n))}{t}{' ' * (20 - len(t))}{make_graph(p)} {p:05.2f} % " for n, t, p in top_data]
|
||||
top_data = sorted(data[:top_num], key=lambda record: record[2]) if sort else data[:top_num]
|
||||
data_list = [f"{n[:25]}{' ' * (25 - len(n))}{t}{' ' * (20 - len(t))}{make_graph(p)} {p:05.2f} % " for n, t, p in top_data]
|
||||
return '\n'.join(data_list)
|
||||
|
||||
|
||||
@@ -73,25 +73,25 @@ async def make_commit_day_time_list(time_zone: str) -> str:
|
||||
sum_week = sum(week_days)
|
||||
day_times = day_times[1:] + day_times[:1]
|
||||
|
||||
day_time_names = [f"{DAY_TIME_EMOJI[i]} {LM.t(DAY_TIME_NAMES[i])}" for i in range(len(day_times))]
|
||||
day_time_texts = [f'{day_time} commits' for day_time in day_times]
|
||||
day_time_percents = [round((day_time / sum_day) * 100, 2) for day_time in day_times]
|
||||
dt_names = [f"{DAY_TIME_EMOJI[i]} {LM.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]
|
||||
title = LM.t("I am an Early") if sum(day_times[0:2]) >= sum(day_times[2:4]) else LM.t("I am a Night")
|
||||
stats += f"**{title}** \n\n```text\n{make_list(names=day_time_names, texts=day_time_texts, percents=day_time_percents, top_num=7)}\n\n```\n"
|
||||
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:
|
||||
week_day_names = [LM.t(week_day) for week_day in WEEK_DAY_NAMES]
|
||||
week_day_texts = [f'{week_day} commits' for week_day in week_days]
|
||||
week_day_percents = [round((week_day / sum_week) * 100, 2) for week_day in week_days]
|
||||
title = LM.t("I am Most Productive on") % week_day_names[week_day_percents.index(max(week_day_percents))]
|
||||
stats += f"📅 **{title}** \n\n```text\n{make_list(names=week_day_names, texts=week_day_texts, percents=week_day_percents, top_num=7)}\n\n```\n"
|
||||
wd_names = [LM.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]
|
||||
title = LM.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"
|
||||
|
||||
return stats
|
||||
|
||||
|
||||
def make_language_per_repo_list(result: Dict) -> str:
|
||||
def make_language_per_repo_list(repositories: Dict) -> str:
|
||||
language_count = dict()
|
||||
repos_with_language = [repo for repo in result["data"]["user"]["repositories"]["edges"] if repo["node"]["primaryLanguage"] is not None]
|
||||
repos_with_language = [repo for repo in repositories["data"]["user"]["repositories"]["edges"] if repo["node"]["primaryLanguage"] is not None]
|
||||
for repo in repos_with_language:
|
||||
language = repo["node"]["primaryLanguage"]["name"]
|
||||
language_count[language] = language_count.get(language, {"count": 0})
|
||||
|
||||
Reference in New Issue
Block a user