From 54ce80f1b02683d286afb771cd5366886afda7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F?= <250213850@qq.com> Date: Fri, 5 Aug 2022 10:08:26 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E6=BC=8F=E6=96=97=E5=88=86?= =?UTF-8?q?=E6=9E=90=E7=94=A8int=E7=B1=BB=E5=9E=8B=E5=88=86=E7=BB=84?= =?UTF-8?q?=E5=87=BA=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/query.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/api/api_v1/endpoints/query.py b/api/api_v1/endpoints/query.py index 04efcf4..83fe2b2 100644 --- a/api/api_v1/endpoints/query.py +++ b/api/api_v1/endpoints/query.py @@ -392,8 +392,8 @@ async def event_model( if item.get('groups'): item['groups'] = np.array(item['groups'])[sort_key].tolist() groups = [] - groupbys=analysis.event_view.get('groupBy') - groupby_list=[i['columnName'] for i in groupbys] + # groupbys=analysis.event_view.get('groupBy') + # groupby_list=[i['columnName'] for i in groupbys] for gitem in item['groups']: gb = [] if '(' in gitem or '[' in gitem: @@ -411,15 +411,15 @@ async def event_model( gb.insert(idx, name) # 去掉分组表现里面的'' - # appgb = str(gb).replace("'", '') - # groups.append(appgb) - # item['groups'] = groups - #修改后的方案 - by_dict={} - for i in range(len(gb)): - by_dict[groupby_list[i]]=gb[i] - groups.append(by_dict) + appgb = str(gb).replace("'", '') + groups.append(appgb) item['groups'] = groups + #修改后的方案 + # by_dict={} + # for i in range(len(gb)): + # by_dict[groupby_list[i]]=gb[i] + # groups.append(by_dict) + # item['groups'] = groups else: if group_label: groups = [] @@ -733,7 +733,11 @@ async def retention_model(request: Request, summary_valuess.pop("['均值']") new_summary_valuess = {} for group_key, group_data in summary_valuess.items(): - key_list = eval(group_key) + # 单个分组 + if len(true_group) <= 1: + key_list = [group_key] + else: + key_list = eval(group_key) true_key = [] # 重新定义后的分组 for index, value in enumerate(key_list): @@ -1168,7 +1172,7 @@ async def funnel_model( # tmp['p2'].append(round(v*100 / tmp_df.loc[i - 1, 'values'], 2)) _ = date_data.setdefault(key[0].strftime('%Y-%m-%d'), {}) - #_[key[1]] = tmp + #[key[1]] = tmp title = (groupby or ['总体']) + cond_level resp = {'list': data_list, 'date_data': date_data,