|
|
|
@ -9,6 +9,7 @@ from src.aeros_simulation.model import AerosSimulation
|
|
|
|
from src.aeros_simulation.service import (
|
|
|
|
from src.aeros_simulation.service import (
|
|
|
|
get_calc_result_by,
|
|
|
|
get_calc_result_by,
|
|
|
|
get_default_simulation,
|
|
|
|
get_default_simulation,
|
|
|
|
|
|
|
|
get_forecast_trending,
|
|
|
|
get_simulation_by_id,
|
|
|
|
get_simulation_by_id,
|
|
|
|
get_simulation_node_by,
|
|
|
|
get_simulation_node_by,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
@ -131,9 +132,13 @@ async def get_model_data(*, db_session: DbSession, simulation_id: Optional[UUID]
|
|
|
|
"WTP": 98,
|
|
|
|
"WTP": 98,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Fetch Forecasts
|
|
|
|
# Fetch Forecasts - latest single point (for summary cards)
|
|
|
|
forecast_weekly = await get_latest_sim_results_by_pattern(db_session, "Simulation_weekly_%")
|
|
|
|
forecast_weekly_latest = await get_latest_sim_results_by_pattern(db_session, "Simulation_weekly_%")
|
|
|
|
forecast_monthly = await get_latest_sim_results_by_pattern(db_session, "Simulation_monthly_%")
|
|
|
|
forecast_monthly_latest = await get_latest_sim_results_by_pattern(db_session, "Simulation_monthly_%")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Fetch Forecast Trending - historical arrays for both weekly and monthly
|
|
|
|
|
|
|
|
forecast_weekly_trending = await get_forecast_trending(db_session=db_session, time_range="weekly", limit=12)
|
|
|
|
|
|
|
|
forecast_monthly_trending = await get_forecast_trending(db_session=db_session, time_range="monthly", limit=12)
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
"id": str(simulation.id),
|
|
|
|
"id": str(simulation.id),
|
|
|
|
@ -158,8 +163,10 @@ async def get_model_data(*, db_session: DbSession, simulation_id: Optional[UUID]
|
|
|
|
"Real_Derating": Derating
|
|
|
|
"Real_Derating": Derating
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"powerplant_reliability": powerplant_reliability,
|
|
|
|
"powerplant_reliability": powerplant_reliability,
|
|
|
|
"forecast_weekly": forecast_weekly,
|
|
|
|
"forecast_weekly": forecast_weekly_latest,
|
|
|
|
"forecast_monthly": forecast_monthly
|
|
|
|
"forecast_monthly": forecast_monthly_latest,
|
|
|
|
|
|
|
|
"forecast_weekly_trending": forecast_weekly_trending,
|
|
|
|
|
|
|
|
"forecast_monthly_trending": forecast_monthly_trending,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async def get_latest_sim_results_by_pattern(db_session: DbSession, pattern: str):
|
|
|
|
async def get_latest_sim_results_by_pattern(db_session: DbSession, pattern: str):
|
|
|
|
@ -167,7 +174,7 @@ async def get_latest_sim_results_by_pattern(db_session: DbSession, pattern: str)
|
|
|
|
from src.aeros_simulation.model import AerosSimulation, AerosSimulationCalcResult, AerosNode
|
|
|
|
from src.aeros_simulation.model import AerosSimulation, AerosSimulationCalcResult, AerosNode
|
|
|
|
from src.aeros_simulation.service import get_plant_calc_result
|
|
|
|
from src.aeros_simulation.service import get_plant_calc_result
|
|
|
|
|
|
|
|
|
|
|
|
query = select(AerosSimulation).where(AerosSimulation.simulation_name.like(pattern)).order_by(AerosSimulation.created_at.desc()).limit(1)
|
|
|
|
query = select(AerosSimulation).where(AerosSimulation.simulation_name.like(pattern)).where(AerosSimulation.status == "completed").order_by(AerosSimulation.created_at.desc()).limit(1)
|
|
|
|
result = await db_session.execute(query)
|
|
|
|
result = await db_session.execute(query)
|
|
|
|
simulation = result.scalars().first()
|
|
|
|
simulation = result.scalars().first()
|
|
|
|
|
|
|
|
|
|
|
|
|