From 0206d806a4bd6c2f3de76a41e3aa36021087440c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80=C3=AE=C3=97=C3=9A=C3=95=C3=B1?= Date: Mon, 19 Sep 2022 11:15:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E4=BC=98=E5=8C=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/forms.py | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/api/api_v1/endpoints/forms.py b/api/api_v1/endpoints/forms.py index 74206ae..273b649 100644 --- a/api/api_v1/endpoints/forms.py +++ b/api/api_v1/endpoints/forms.py @@ -1122,25 +1122,25 @@ async def stage_success_form( chk_num5 = res_data['wait_work_num'] chk_num7 = res_data['work_in_num'] if chk_num1 and chk_num2: - chance_1 = round(chk_num2 / chk_num1, 2) + chance_1 = '{:.2%}'.format(chk_num2 / chk_num1) else: - chance_1 = 0 + chance_1 = '0%' if chk_num2 and chk_num3: - chance_2 = round(chk_num3 / chk_num2, 2) + chance_2 = '{:.2%}'.format(chk_num3 / chk_num2) else: - chance_2 = 0 + chance_2 = '0%' if chk_num3 and chk_num4: - chance_3 = round(chk_num4 / chk_num3, 2) + chance_3 = '{:.2%}'.format(chk_num4 / chk_num3) else: - chance_3 = 0 + chance_3 = '0%' if chk_num4 and chk_num5: - chance_4 = round(chk_num5 / chk_num4, 2) + chance_4 = '{:.2%}'.format(chk_num5 / chk_num4) else: - chance_4 = 0 + chance_4 = '0%' if chk_num5 and chk_num7: - chance_5 = round(chk_num7 / chk_num5, 2) + chance_5 = '{:.2%}'.format(chk_num7 / chk_num5) else: - chance_5 = 0 + chance_5 = '0%' res_msg[res_name].update({ 'chance_1': chance_1, 'chance_2': chance_2, @@ -1525,14 +1525,14 @@ async def owner_form( work_num = len([1 for i in data_list if i['interview_stage'] >= 7]) if offer_num: - offer_chance = round(offer_num / count_num, 2) + offer_chance = '{:.2%}'.format(offer_num / count_num) else: - offer_chance = 0 + offer_chance = '0%' if work_num: - work_chance = round(work_num / count_num, 2) + work_chance = '{:.2%}'.format(work_num / count_num) else: - work_chance = 0 + work_chance = '0%' res_msg[key]['count'] = count_num res_msg[key]['offer_num'] = offer_num res_msg[key]['work_num'] = work_num @@ -2059,17 +2059,17 @@ async def find_worker_form( res_data.append(res_msg1) res_msg2 = { 'title': '占比', - '未评级': round(res_msg1['未评级'] / res_msg['总人数'], 2), - 'p1-p3': round(res_msg1['p1-p3'] / res_msg['总人数'], 2), - 'p4': round(res_msg1['p4'] / res_msg['总人数'], 2), - 'p5': round(res_msg1['p5'] / res_msg['总人数'], 2), - 'p6': round(res_msg1['p6'] / res_msg['总人数'], 2), - 'p7': round(res_msg1['p7'] / res_msg['总人数'], 2), - 'p8': round(res_msg1['p8'] / res_msg['总人数'], 2), - 'm1': round(res_msg1['m1'] / res_msg['总人数'], 2), - 'm2': round(res_msg1['m2'] / res_msg['总人数'], 2), - 'm3': round(res_msg1['m3'] / res_msg['总人数'], 2), - 'm4': round(res_msg1['m4'] / res_msg['总人数'], 2), + '未评级': '{:.2%}'.format(res_msg1['未评级'] / res_msg['总人数']), + 'p1-p3': '{:.2%}'.format(res_msg1['p1-p3'] / res_msg['总人数']), + 'p4': '{:.2%}'.format(res_msg1['p4'] / res_msg['总人数']), + 'p5': '{:.2%}'.format(res_msg1['p5'] / res_msg['总人数']), + 'p6': '{:.2%}'.format(res_msg1['p6'] / res_msg['总人数']), + 'p7': '{:.2%}'.format(res_msg1['p7'] / res_msg['总人数']), + 'p8': '{:.2%}'.format(res_msg1['p8'] / res_msg['总人数']), + 'm1': '{:.2%}'.format(res_msg1['m1'] / res_msg['总人数']), + 'm2': '{:.2%}'.format(res_msg1['m2'] / res_msg['总人数']), + 'm3': '{:.2%}'.format(res_msg1['m3'] / res_msg['总人数']), + 'm4': '{:.2%}'.format(res_msg1['m4'] / res_msg['总人数']), } res_data.append(res_msg2) level_list = {