1.优化事件分析int类型分组按数值大小排序
This commit is contained in:
parent
adbf77ce8e
commit
20ea6efd44
@ -438,7 +438,33 @@ async def event_model(
|
|||||||
item['sum'] = np.array(item['sum'])[sort_key].tolist()
|
item['sum'] = np.array(item['sum'])[sort_key].tolist()
|
||||||
item['avg'] = np.array(item['avg'])[sort_key].tolist()
|
item['avg'] = np.array(item['avg'])[sort_key].tolist()
|
||||||
res = [item for idx, item in enumerate(res) if idx not in is_hide]
|
res = [item for idx, item in enumerate(res) if idx not in is_hide]
|
||||||
|
# 对单个为int的分组进行排序
|
||||||
|
if analysis.event_view.get('groupBy','') !=[] and analysis.event_view.get('groupBy','') != '':
|
||||||
|
if analysis.event_view.get('groupBy','')[0]['data_type'] == 'int' and len(analysis.event_view.get('groupBy','')) == 1 and len(res[0]['groups']) > 1:
|
||||||
|
short_list = sorted([ast.literal_eval(i)[0] for i in res[0]['groups']])
|
||||||
|
idx_list = []
|
||||||
|
for date in res[0]['groups']:
|
||||||
|
for id, i in enumerate(short_list):
|
||||||
|
if date == f'[{i}]':
|
||||||
|
idx_list.append(id)
|
||||||
|
break
|
||||||
|
for i in ['groups', 'values', 'sum', 'avg']:
|
||||||
|
ad = [0 for nu in range(len(idx_list))]
|
||||||
|
for idx, ii in enumerate(idx_list):
|
||||||
|
ad[ii] = res[0][i][idx]
|
||||||
|
res[0][i] = ad
|
||||||
|
# 计算每一天的总和
|
||||||
|
# if res[0]['event_name'] == '充值排行':
|
||||||
|
# zong=[]
|
||||||
|
# lens=len(res[0]['date_range'])
|
||||||
|
# for nu in range(lens):
|
||||||
|
# aa=0
|
||||||
|
# for value in res[0]['values']:
|
||||||
|
# aa+=value[nu]
|
||||||
|
# zong.append(aa)
|
||||||
|
# res[0]['zong']=zong
|
||||||
|
# else:
|
||||||
|
# res[0]['zong'] = []
|
||||||
return schemas.Msg(code=0, msg='ok', data=res)
|
return schemas.Msg(code=0, msg='ok', data=res)
|
||||||
|
|
||||||
|
|
||||||
@ -1887,6 +1913,11 @@ async def scatter_model(
|
|||||||
ac = ast.literal_eval(i)
|
ac = ast.literal_eval(i)
|
||||||
ab = [str(ii) for ii in ac]
|
ab = [str(ii) for ii in ac]
|
||||||
groupby_data.append(ab)
|
groupby_data.append(ab)
|
||||||
|
# if not isinstance(ac,int):
|
||||||
|
# ab = [str(ii) for ii in ac]
|
||||||
|
# groupby_data.append(ab)
|
||||||
|
# else:
|
||||||
|
# groupby_data.append(ac)
|
||||||
resp['groupby_data'] = groupby_data
|
resp['groupby_data'] = groupby_data
|
||||||
return schemas.Msg(code=0, msg='ok', data=resp)
|
return schemas.Msg(code=0, msg='ok', data=resp)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user