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}'))