|
|
|
|
@ -5,6 +5,7 @@ from .model import PlantTransactionData
|
|
|
|
|
from .schema import (
|
|
|
|
|
PlantTransactionDataPagination,
|
|
|
|
|
PlantTransactionDataRead,
|
|
|
|
|
PlantChartData,
|
|
|
|
|
PlantTransactionChart,
|
|
|
|
|
PlantTransactionDataCreate,
|
|
|
|
|
PlantTransactionDataUpdate,
|
|
|
|
|
@ -40,15 +41,24 @@ async def get_transaction_datas(
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/charts", response_model=StandardResponse[List[PlantTransactionChart]])
|
|
|
|
|
@router.get("/charts", response_model=StandardResponse[PlantChartData])
|
|
|
|
|
async def get_chart_data(db_session: DbSession, common: CommonParameters):
|
|
|
|
|
chart_data = await get_charts(db_session=db_session, common=common)
|
|
|
|
|
if not chart_data:
|
|
|
|
|
chart_data, bep_year, bep_total_lcc = await get_charts(
|
|
|
|
|
db_session=db_session, common=common
|
|
|
|
|
)
|
|
|
|
|
if not chart_data or not bep_year:
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
|
|
|
detail="A data with this id does not exist.",
|
|
|
|
|
)
|
|
|
|
|
return StandardResponse(data=chart_data, message="Data retrieved successfully")
|
|
|
|
|
return StandardResponse(
|
|
|
|
|
data={
|
|
|
|
|
"items": chart_data,
|
|
|
|
|
"bep_year": bep_year,
|
|
|
|
|
"bep_total_lcc": bep_total_lcc,
|
|
|
|
|
},
|
|
|
|
|
message="Data retrieved successfully",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get(
|
|
|
|
|
|