去掉当日留存

This commit is contained in:
wuaho 2021-09-18 15:24:22 +08:00
parent 577761583b
commit 7d7a3801c3
3 changed files with 15 additions and 13 deletions

View File

@ -91,7 +91,8 @@ async def add_policy(
res = 0
for path in data_id.path_list:
res = casbin_enforcer.add_policy(data_id.role_id, data_id.game, path, data_id.act)
casbin_enforcer.load_model()
# casbin_enforcer.load_model()
casbin_enforcer.load_policy()
return schemas.Msg(code=0, msg='ok', data=res)
@ -105,7 +106,8 @@ async def remove_policy(
"""
res = casbin_enforcer.remove_policy(data_id.role_id, data_id.game, data_id.path, data_id.act)
casbin_enforcer.load_model()
# casbin_enforcer.load_model()
casbin_enforcer.load_policy()
return schemas.Msg(code=0, msg='ok', data=res)

View File

@ -293,7 +293,7 @@ async def retention_model(request: Request,
for i in set(date_range) - set(df.index):
df.loc[i] = 0
df.sort_index(inplace=True)
days = [i for i in range(unit_num + 1)]
days = [i for i in range(1,unit_num + 1)]
summary_values = {}
today = datetime.datetime.today().date()
@ -304,7 +304,7 @@ async def retention_model(request: Request,
tmp['n'] = []
tmp['p_outflow'] = []
tmp['n_outflow'] = []
for i in range((today - date).days + 1):
for i in range(1, (today - date).days + 1):
if i > unit_num:
break
p = float(getattr(value, f'p{i + 1}'))
@ -661,14 +661,14 @@ async def scatter_model(
resp['list'][key.strftime('%Y-%m-%d')] = {'n': total, 'total': total, 'p': 100}
return schemas.Msg(code=0, msg='ok', data=resp)
# bins_s = pd.cut(tmp_df['values'], bins=bins,
# right=False).value_counts()
# bins_s.sort_index(inplace=True)
# total = int(bins_s.sum())
# resp['list'][key.strftime('%Y-%m-%d')] = dict()
# resp['list'][key.strftime('%Y-%m-%d')]['总体'] = {'n': bins_s.to_list(), 'total': total,
# 'p': round(bins_s * 100 / total, 2).to_list(),
# 'title': '总体'}
# bins_s = pd.cut(tmp_df['values'], bins=bins,
# right=False).value_counts()
# bins_s.sort_index(inplace=True)
# total = int(bins_s.sum())
# resp['list'][key.strftime('%Y-%m-%d')] = dict()
# resp['list'][key.strftime('%Y-%m-%d')]['总体'] = {'n': bins_s.to_list(), 'total': total,
# 'p': round(bins_s * 100 / total, 2).to_list(),
# 'title': '总体'}
@router.post("/trace_model_sql")

View File

@ -801,7 +801,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(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}""")