update
This commit is contained in:
parent
c28d32491a
commit
0888cc88fc
@ -369,6 +369,8 @@ async def scatter_model(
|
|||||||
resp['label'].append(f'[{quota_interval_arr[i]},{v})')
|
resp['label'].append(f'[{quota_interval_arr[i]},{v})')
|
||||||
bins.append(v)
|
bins.append(v)
|
||||||
|
|
||||||
|
summary_data = None
|
||||||
|
# todo 整体的,需要补充分组的
|
||||||
for key, tmp_df in df.groupby('date'):
|
for key, tmp_df in df.groupby('date'):
|
||||||
bins_s = pd.cut(tmp_df['values'], bins=bins,
|
bins_s = pd.cut(tmp_df['values'], bins=bins,
|
||||||
right=False).value_counts()
|
right=False).value_counts()
|
||||||
@ -379,7 +381,7 @@ async def scatter_model(
|
|||||||
return schemas.Msg(code=0, msg='ok', data=resp)
|
return schemas.Msg(code=0, msg='ok', data=resp)
|
||||||
|
|
||||||
if interval_type == 'def' and analysis == 'number_of_days':
|
if interval_type == 'def' and analysis == 'number_of_days':
|
||||||
resp = {}
|
resp = {'list': {}}
|
||||||
for key, tmp_df in df.groupby('date'):
|
for key, tmp_df in df.groupby('date'):
|
||||||
total = int(tmp_df['values'].sum())
|
total = int(tmp_df['values'].sum())
|
||||||
resp['list'][key.strftime('%Y-%m-%d')] = {'n': total, 'total': total, 'p': 100}
|
resp['list'][key.strftime('%Y-%m-%d')] = {'n': total, 'total': total, 'p': 100}
|
||||||
|
@ -299,12 +299,15 @@ ORDER BY level
|
|||||||
event_name_col == event_name
|
event_name_col == event_name
|
||||||
|
|
||||||
]
|
]
|
||||||
|
values_col = func.count().label('values')
|
||||||
|
if analysis in ['number_of_days', 'number_of_hours']:
|
||||||
|
values_col = func.count(func.distinct(e_account_id_col)).label('values')
|
||||||
|
|
||||||
if analysis in ['times', 'number_of_days', 'number_of_hours']:
|
if analysis in ['times', 'number_of_days', 'number_of_hours']:
|
||||||
|
|
||||||
qry = sa.select(event_date_col, func.count().label('values')) \
|
qry = sa.select(event_date_col, values_col) \
|
||||||
.where(and_(*where)) \
|
.where(and_(*where)) \
|
||||||
.group_by(event_date_col, e_account_id_col)
|
.group_by(event_date_col, *self.groupby, e_account_id_col)
|
||||||
|
|
||||||
sql = str(qry.compile(compile_kwargs={"literal_binds": True}))
|
sql = str(qry.compile(compile_kwargs={"literal_binds": True}))
|
||||||
print(sql)
|
print(sql)
|
||||||
@ -319,7 +322,7 @@ ORDER BY level
|
|||||||
|
|
||||||
qry = sa.select(event_date_col, settings.CK_FUNC[analysis](event_attr_col).label('values')) \
|
qry = sa.select(event_date_col, settings.CK_FUNC[analysis](event_attr_col).label('values')) \
|
||||||
.where(and_(*where)) \
|
.where(and_(*where)) \
|
||||||
.group_by(event_date_col, e_account_id_col)
|
.group_by(event_date_col, *self.groupby, e_account_id_col)
|
||||||
sql = str(qry.compile(compile_kwargs={"literal_binds": True}))
|
sql = str(qry.compile(compile_kwargs={"literal_binds": True}))
|
||||||
print(sql)
|
print(sql)
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user