From aaa4cd63ee99005df92993749a2ed79fdcafefa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F?= <250213850@qq.com> Date: Sat, 7 May 2022 18:51:54 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E5=88=86=E5=B8=83=E5=88=86?= =?UTF-8?q?=E6=9E=90=E5=85=83=E7=B4=A0=E5=8E=BB=E9=87=8D=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=8E=BB=E9=87=8D=E6=95=B0=EF=BC=8C=E9=9B=86?= =?UTF-8?q?=E5=90=88=E5=8E=BB=E9=87=8D=E6=95=B0=E6=B2=A1=E6=9C=89=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=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 | 11 ++++++----- core/config.py | 13 ++++++++++++- models/behavior_analysis.py | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/api/api_v1/endpoints/query.py b/api/api_v1/endpoints/query.py index 496cde9..79f3f3c 100644 --- a/api/api_v1/endpoints/query.py +++ b/api/api_v1/endpoints/query.py @@ -1015,9 +1015,9 @@ async def scatter_model( if df.empty: return schemas.Msg(code=-9, msg='无数据', data=None) if 'list' in str(type(df['values'][0])): - f=lambda x:x[0] - df['values']=df['values'].map(f) - + # f=lambda x:x[0] + # df['values']=df['values'].map(f) + df = df.explode("values").reset_index(drop=True) #df['values']=df['values'].astype(str) df.fillna(0, inplace=True) #转换数据类型为int @@ -1190,8 +1190,9 @@ async def scatter_model( if df.empty: return schemas.Msg(code=-9, msg='无数据', data=None) if 'list' in str(type(df['values'][0])): - f = lambda x: x[0] - df['values'] = df['values'].map(f) + # f = lambda x: x[0] + # df['values'] = df['values'].map(f) + df = df.explode("values").reset_index(drop=True) df.fillna(0, inplace=True) # 转换数据类型为int df['values'] = df['values'].astype(int) diff --git a/core/config.py b/core/config.py index 50542e5..c19f647 100644 --- a/core/config.py +++ b/core/config.py @@ -295,6 +295,16 @@ class Settings(BaseSettings): 'id': 'not in', 'title': '不是' }, + ], + 'array': [ + { + 'id': 'is not null', + 'title': '有值' + }, + { + 'id': 'is null', + 'title': '无值' + } ] } ARITHMETIC = { @@ -302,6 +312,7 @@ class Settings(BaseSettings): '-': lambda x, y: x - y, '*': lambda x, y: x * y, '/': lambda x, y: x / y, + #'%': lambda x, y:(x)-int(x/y)*(y) 取模用 } PROPHET_TIME_GRAIN_MAP = { @@ -389,7 +400,7 @@ class Settings(BaseSettings): class Debug(Settings): - MDB_HOST: str = '10.0.0.7' + MDB_HOST: str = '10.0.0.9' MDB_PORT: int = 27017 MDB_USER: str = 'root' MDB_PASSWORD: str = 'iamciniao' diff --git a/models/behavior_analysis.py b/models/behavior_analysis.py index 98a0c66..ca2e780 100644 --- a/models/behavior_analysis.py +++ b/models/behavior_analysis.py @@ -611,7 +611,7 @@ ORDER BY level event = self.events[0] event_name = event['eventName'] analysis = event['analysis'] - if analysis == 'list_distinct': + if analysis in ['list_distinct',"set_distinct","ele_distinct"]: analysis = 'max' e_account_id_col = getattr(self.event_tbl.c, '#account_id').label('uid') u_account_id_col = getattr(self.user_tbl.c, '#account_id')