首页合格率计算
This commit is contained in:
parent
f29a5ee5e4
commit
5c2751baa9
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue