diff --git a/api/api_v1/endpoints/query.py b/api/api_v1/endpoints/query.py index c44769a..56fcb08 100644 --- a/api/api_v1/endpoints/query.py +++ b/api/api_v1/endpoints/query.py @@ -20,6 +20,7 @@ from db.redisdb import get_redis_pool, RedisDrive from models.behavior_analysis import BehaviorAnalysis, CombinationEvent from models.user_analysis import UserAnalysis +from models.x_analysis import XAnalysis from utils import DfToStream router = APIRouter() @@ -961,6 +962,9 @@ async def scatter_model( await analysis.init(data_where=current_user.data_where) event_type = analysis.events[0]['eventName'] res = await analysis.scatter_model_sql() + end_date=analysis.end_date + start_date=analysis.start_date + where=analysis.events[-1]['quotaname'] sql = res['sql'] #查询买量渠道owner为kuaiyou3的日注册玩家等级分布 @@ -1090,6 +1094,14 @@ async def scatter_model( 'p': list_p}} #resp['list'][dt] = {'总体': {'n': [labels_dict.get(i, 0) for i in labels], 'total': total, # 'p': [round(labels_dict.get(i, 0) * 100 / total, 2) for i in labels]}} + if where =="step_id" and event_type == "guide": + sql=f"""SELECT toDate(addHours({game}.event."#event_time", 8)) AS date, count(DISTINCT {game}.event."#account_id") AS values FROM {game}.event WHERE addHours({game}.event."#event_time", 8) >= '{start_date}' AND addHours({game}.event."#event_time", 8) <= '{end_date}' AND {game}.event."#event_name" = 'create_account' GROUP BY toDate(addHours({game}.event."#event_time", 8)) ORDER BY date""" + df = await ckdb.query_dataframe(sql) + for i in range(len(df)): + resp['list'][str(df['date'][i])]['总体']['total']=int(df['values'][i]) + + + return schemas.Msg(code=0, msg='ok', data=resp) # bins_s = pd.cut(tmp_df['values'], bins=bins, @@ -1241,4 +1253,6 @@ async def user_property_model( return schemas.Msg(code=0, msg='ok', data={ 'value': data, 'title': title - }) \ No newline at end of file + }) + +