diff --git a/models/behavior_analysis.py b/models/behavior_analysis.py index daf7368..d6ed3b7 100644 --- a/models/behavior_analysis.py +++ b/models/behavior_analysis.py @@ -40,7 +40,7 @@ class CombinationEvent: result = round(result, 2) elif self.format == 'integer': result = result.astype(int) - return result.to_list(), result.sum(), round(result.mean(), 2) + return result.to_list(), round(result.sum(), 2), round(result.mean(), 2) class CustomEvent: @@ -641,7 +641,8 @@ ORDER BY level elif event.get('quota'): event_attr_col = getattr(self.event_tbl.c, event['quota']) - qry = sa.select(event_date_col,e_account_id_col, settings.CK_FUNC[analysis](event_attr_col).label('values')) \ + qry = sa.select(event_date_col, e_account_id_col, + settings.CK_FUNC[analysis](event_attr_col).label('values')) \ .where(and_(*where)) \ .group_by(event_date_col, *self.groupby, e_account_id_col) sql = str(qry.compile(compile_kwargs={"literal_binds": True})) @@ -801,7 +802,7 @@ ORDER BY values desc""" days = (arrow.get(self.end_date).date() - arrow.get(self.start_date).date()).days keep = [] cnt = [] - for i in range(1,days + 1): + for i in range(1, days + 1): keep.append( f"""cnt{i + 1},round(cnt{i + 1} * 100 / cnt0, 2) as `p{i + 1}`""") cnt.append(f"""sum(if(dateDiff('day',a.reg_date,b.visit_date)={i},1,0)) as cnt{i + 1}""")