From 77ca70cc6c92bbe5ac5c14c2235c909ce6af3ac5 Mon Sep 17 00:00:00 2001 From: wuaho Date: Thu, 9 Sep 2021 17:28:49 +0800 Subject: [PATCH] 1 --- api/api_v1/endpoints/xquery.py | 6 +++--- models/x_analysis.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/api_v1/endpoints/xquery.py b/api/api_v1/endpoints/xquery.py index f4e604c..23dcbe7 100644 --- a/api/api_v1/endpoints/xquery.py +++ b/api/api_v1/endpoints/xquery.py @@ -32,7 +32,7 @@ async def ltv_model_sql( current_user: schemas.UserDB = Depends(deps.get_current_user) ) -> schemas.Msg: """ ltv模型sql """ - await analysis.init() + await analysis.init(data_where=current_user.data_where) data = analysis.ltv_model_sql() return schemas.Msg(code=0, msg='ok', data=[data]) @@ -46,7 +46,7 @@ async def ltv_model_sql( current_user: schemas.UserDB = Depends(deps.get_current_user) ) -> schemas.Msg: """ ltv模型sql """ - await analysis.init() + await analysis.init(data_where=current_user.data_where) res = analysis.ltv_model_sql() sql = res['sql'] @@ -76,7 +76,7 @@ async def ltv_model_export(request: Request, current_user: schemas.UserDB = Depends(deps.get_current_user) ): """ ltv分析 数据导出""" - await analysis.init() + await analysis.init(data_where=current_user.data_where) data = analysis.ltv_model_sql() file_name = quote(f'lvt.xlsx') mime = mimetypes.guess_type(file_name)[0] diff --git a/models/x_analysis.py b/models/x_analysis.py index 3695d43..d6a4b1c 100644 --- a/models/x_analysis.py +++ b/models/x_analysis.py @@ -29,7 +29,7 @@ class XAnalysis: def _get_global_filters(self): return self.event_view.get('filts') or [] - async def init(self): + async def init(self,*args, **kwargs): if self.data_in.report_id: db = get_database() report = await crud.report.get(db, id=self.data_in.report_id) @@ -52,6 +52,9 @@ class XAnalysis: self.events = self.data_in.events self.global_filters = self._get_global_filters() + # 用户自带过滤 + if 'data_where' in kwargs: + self.global_filters.extend(kwargs['data_where'].get(self.game, [])) def handler_filts(self): where = []