From 0cadeb283aef8b581e8a716a370e7bc26d15ed82 Mon Sep 17 00:00:00 2001 From: wuaho Date: Tue, 26 Oct 2021 22:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=99=E5=AD=98=E6=97=B6=E9=95=BF=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api_v1/endpoints/query.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/api_v1/endpoints/query.py b/api/api_v1/endpoints/query.py index 34cb552..0111c0e 100644 --- a/api/api_v1/endpoints/query.py +++ b/api/api_v1/endpoints/query.py @@ -299,7 +299,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(1, unit_num + 1)] + days = [i for i in range(1, unit_num )] summary_values = {} today = datetime.datetime.today().date() @@ -310,8 +310,8 @@ async def retention_model(request: Request, tmp['n'] = [] tmp['p_outflow'] = [] tmp['n_outflow'] = [] - for i in range(1, (today - date).days + 1): - if i > unit_num: + for i in range(1, (today - date).days): + if i >= unit_num: break p = float(getattr(value, f'p{i + 1}')) n = int(getattr(value, f'cnt{i + 1}'))