mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 20:51:25 +03:00
refactor(chart): Move functions to separate files or folders to improve code structure.
This commit is contained in:
parent
110effaeb2
commit
85acbbb16c
5 changed files with 177 additions and 175 deletions
34
chart/routes/get_chart.py
Normal file
34
chart/routes/get_chart.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
from fastapi import APIRouter, status, Request, Response
|
||||
|
||||
from chart.function.create_chart import create_chart
|
||||
from chart.routes.get_chart_period import prepare_chart_response
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/api/getChart/", status_code=status.HTTP_201_CREATED)
|
||||
async def get_chart(
|
||||
response: Response,
|
||||
request: Request,
|
||||
from_currency: str = None,
|
||||
conv_currency: str = None,
|
||||
start_date: str = None,
|
||||
end_date: str = None,
|
||||
):
|
||||
|
||||
if not from_currency or not conv_currency:
|
||||
response.status_code = status.HTTP_400_BAD_REQUEST
|
||||
return {
|
||||
'status': status.HTTP_400_BAD_REQUEST,
|
||||
'message': 'The from_currency and conv_currency fields are required.',
|
||||
}
|
||||
elif not start_date and not end_date:
|
||||
response.status_code = status.HTTP_400_BAD_REQUEST
|
||||
return {
|
||||
'status': status.HTTP_400_BAD_REQUEST,
|
||||
'message': 'The start_date and end_date fields are required.',
|
||||
}
|
||||
|
||||
|
||||
chart = await create_chart(from_currency, conv_currency, start_date, end_date)
|
||||
|
||||
return await prepare_chart_response(response, request, chart)
|
Loading…
Add table
Reference in a new issue