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