From 32b24ef5187577e50035c4cdcbc2a4c460400365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80=C3=AE=C3=97=C3=9A=C3=95=C3=B1?= Date: Wed, 24 Aug 2022 11:45:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=8B=E4=BB=B6=E9=A6=96?= =?UTF-8?q?=E6=AC=A1=E8=A7=A6=E5=8F=91=E9=97=B4=E9=9A=94=E5=88=86=E6=9E=90?= =?UTF-8?q?1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/query.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/api/api_v1/endpoints/query.py b/api/api_v1/endpoints/query.py index 4cd4b65..b8652a6 100644 --- a/api/api_v1/endpoints/query.py +++ b/api/api_v1/endpoints/query.py @@ -1703,17 +1703,20 @@ async def first_event_model( else: dict_k[key] = sum_num + list_data = [] for i in step_list: if str(i) not in dict_k: - dict_k[str(i)] = 0 + list_data.append(0) + continue + list_data.append(dict_k[str(i)]) - all_num = sum(list(dict_k.values())) - p_data = {key: round(v * 100 / all_num, 2) for key, v in dict_k.items()} + all_num = sum(list_data) + p_data = [round(v * 100 / all_num, 2) for v in list_data] true_step = [str(i) for i in step_list] res_msg = { 'level': true_step, - 'list': dict_k, + 'list': list_data, 'p': p_data } return schemas.Msg(code=0, msg='ok', data=res_msg)