diff --git a/api/api_v1/endpoints/query.py b/api/api_v1/endpoints/query.py index 8e0df31..bf0b9db 100644 --- a/api/api_v1/endpoints/query.py +++ b/api/api_v1/endpoints/query.py @@ -183,7 +183,7 @@ async def event_model( if last_value > 0: q['last_value'] = float(last_value) break - if groupby: + if groupby and (set(groupby) & set(df) == set(groupby)): q['date_range'] = [f'{i}' for i in df.set_index(groupby).index] else: q['date_range'] = ['合计'] @@ -191,7 +191,7 @@ async def event_model( res.append(q) continue - if groupby: + if groupby and (set(groupby) & set(df)) == set(groupby): # 有分组 for group, df_group in df.groupby(groupby): df_group.reset_index(drop=True, inplace=True) @@ -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(1,unit_num + 1)] + days = [i for i in range(1, unit_num + 1)] summary_values = {} today = datetime.datetime.today().date()