From 7ad43f5a6dc77a6d7305196f4a8d0b5a7ae8cb6d Mon Sep 17 00:00:00 2001 From: Redume Date: Tue, 5 Nov 2024 22:32:06 +0300 Subject: [PATCH] fix: Condition of no parameters --- chart/main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/chart/main.py b/chart/main.py index 0914981..41127fc 100644 --- a/chart/main.py +++ b/chart/main.py @@ -40,8 +40,11 @@ app.middleware('http')(PlausibleAnalytics()) async def get_chart( response: Response, request: Request, + from_currency: str = None, + conv_currency: str = None, + start_date: str = None, + end_date: str = None, ): - from_currency, conv_currency, start_date, end_date = None, None, None, None if not from_currency or not conv_currency: response.status_code = status.HTTP_400_BAD_REQUEST @@ -76,10 +79,11 @@ async def get_chart( async def get_chart_period( response: Response, request: Request, + from_currency: str = None, + conv_currency: str = None, + period: str = None, ): - from_currency, conv_currency, period = None, None, None - if not from_currency or not conv_currency: response.status_code = status.HTTP_400_BAD_REQUEST return { @@ -124,7 +128,7 @@ async def get_chart_period( } -async def create_chart(from_currency: str, conv_currency: str, start_date: str, end_date: str) -> (str, bool): +async def create_chart(from_currency: str, conv_currency: str, start_date: str, end_date: str) -> str: cur.execute('SELECT date, rate FROM currency WHERE (date BETWEEN %s AND %s) ' 'AND from_currency = %s AND conv_currency = %s ORDER BY date', [