Update statistics_handle.py

This commit is contained in:
HibiKier 2021-10-08 16:28:04 +08:00 committed by GitHub
parent 6014c3f975
commit 1033d585c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,8 +103,18 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
itype = 'month_statistics'
else:
itype = 'total_statistics'
data = data[itype]["total"]
bar_graph = await init_bar_graph(data, state["_prefix"]["raw_command"])
tmp_dict = {}
data = data[itype]
for group in data.keys():
if group != 'total':
for day in data[group].keys():
for plugin_name in data[group][day].keys():
if data[group][day][plugin_name] is not None:
if tmp_dict.get(plugin_name) is None:
tmp_dict[plugin_name] = 1
else:
tmp_dict[plugin_name] += data[group][day][plugin_name]
bar_graph = await init_bar_graph(tmp_dict, state["_prefix"]["raw_command"])
await asyncio.get_event_loop().run_in_executor(None, bar_graph.gen_graph)
await statistics.finish(image(b64=bar_graph.pic2bs4()))
return