From 5c2751baa9a01af9e3527efff0d9d4c4efef4591 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 19 Jan 2022 15:06:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=90=88=E6=A0=BC=E7=8E=87?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/srm/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hb_server/apps/srm/views.py b/hb_server/apps/srm/views.py index 175c847..57a6a75 100644 --- a/hb_server/apps/srm/views.py +++ b/hb_server/apps/srm/views.py @@ -45,7 +45,7 @@ class ProcessYieldView(CreateAPIView): ret = [] process_l = list(Process.objects.filter(is_deleted=False).order_by('number').values('id', 'name')) for i in process_l: - ret_item = {'id':i['id'], 'name':i['name'], 'count_ok':0, 'count_notok':0, 'rate':0} + ret_item = {'id':i['id'], 'name':i['name'], 'count_ok':0, 'count_notok':0, 'rate':1} for m in count_ok_g: if m['step__process__id'] == ret_item['id']: ret_item['count_ok'] = m['count_ok'] @@ -53,7 +53,7 @@ class ProcessYieldView(CreateAPIView): if n['step__process__id'] == ret_item['id']: ret_item['count_notok'] = n['count_notok'] rate = (ret_item['count_ok']/(ret_item['count_ok']+ret_item['count_notok'])) \ - if ret_item['count_ok']+ret_item['count_notok']>0 else 0 + if ret_item['count_ok']+ret_item['count_notok']>0 else 1 ret_item['rate'] = rate ret.append(ret_item) return Response(ret)