1.新增事件分析中加减乘除的运算
This commit is contained in:
parent
bbbfa90275
commit
aced6844d3
@ -381,8 +381,8 @@ class BehaviorAnalysis:
|
|||||||
async def event_model_sql(self):
|
async def event_model_sql(self):
|
||||||
sqls = []
|
sqls = []
|
||||||
event_time_col = getattr(self.event_tbl.c, '#event_time')
|
event_time_col = getattr(self.event_tbl.c, '#event_time')
|
||||||
|
|
||||||
for event in self.events:
|
for event in self.events:
|
||||||
|
operator_ = event.get('operator_val','')
|
||||||
event_name_display = event.get('eventNameDisplay')
|
event_name_display = event.get('eventNameDisplay')
|
||||||
is_show = event.get('is_show', True)
|
is_show = event.get('is_show', True)
|
||||||
|
|
||||||
@ -450,19 +450,35 @@ class BehaviorAnalysis:
|
|||||||
# 按账号聚合
|
# 按账号聚合
|
||||||
e_account_id_col = getattr(self.event_tbl.c, '#account_id')
|
e_account_id_col = getattr(self.event_tbl.c, '#account_id')
|
||||||
|
|
||||||
# 聚合方式
|
if operator_ == '':
|
||||||
if analysis == 'total_count':
|
# 聚合方式
|
||||||
selectd = select_exprs + [func.count().label('values')]
|
if analysis == 'total_count':
|
||||||
elif analysis == 'touch_user_count':
|
selectd = select_exprs + [func.count().label('values')]
|
||||||
selectd = select_exprs + [func.count(sa.distinct(e_account_id_col)).label('values')]
|
elif analysis == 'touch_user_count':
|
||||||
elif analysis == 'touch_user_avg':
|
selectd = select_exprs + [func.count(sa.distinct(e_account_id_col)).label('values')]
|
||||||
selectd = select_exprs + [
|
elif analysis == 'touch_user_avg':
|
||||||
func.round((func.count() / func.count(sa.distinct(e_account_id_col))), 2).label(
|
selectd = select_exprs + [
|
||||||
'values')]
|
func.round((func.count() / func.count(sa.distinct(e_account_id_col))), 2).label(
|
||||||
|
'values')]
|
||||||
|
else:
|
||||||
|
selectd = select_exprs + [
|
||||||
|
func.round(getattr(func, analysis)(getattr(self.event_tbl.c, event['event_attr_id'])), 2).label(
|
||||||
|
'values')]
|
||||||
else:
|
else:
|
||||||
selectd = select_exprs + [
|
operator_val=int(operator_)
|
||||||
func.round(getattr(func, analysis)(getattr(self.event_tbl.c, event['event_attr_id'])), 2).label(
|
operator=event['operator'] #运算符号
|
||||||
'values')]
|
if analysis == 'total_count':
|
||||||
|
selectd = select_exprs + [settings.ARITHMETIC[operator](func.count(),operator_val).label('values')]
|
||||||
|
elif analysis == 'touch_user_count':
|
||||||
|
selectd = select_exprs + [settings.ARITHMETIC[operator](func.count(sa.distinct(e_account_id_col)),operator_val).label('values')]
|
||||||
|
elif analysis == 'touch_user_avg':
|
||||||
|
selectd = select_exprs + [
|
||||||
|
settings.ARITHMETIC[operator](func.round((func.count() / func.count(sa.distinct(e_account_id_col))), 2),operator_val).label(
|
||||||
|
'values')]
|
||||||
|
else:
|
||||||
|
selectd = select_exprs + [
|
||||||
|
settings.ARITHMETIC[operator](func.round(getattr(func, analysis)(getattr(self.event_tbl.c, event['event_attr_id'])), 2),operator_val).label(
|
||||||
|
'values')]
|
||||||
|
|
||||||
if user_filter:
|
if user_filter:
|
||||||
qry = sa.select(selectd).select_from(
|
qry = sa.select(selectd).select_from(
|
||||||
|
Loading…
Reference in New Issue
Block a user