|
|
|
@ -526,9 +526,7 @@ async def process_calc_results_streaming(
|
|
|
|
|
|
|
|
|
|
|
|
# Parse nodeResultOuts array incrementally
|
|
|
|
# Parse nodeResultOuts array incrementally
|
|
|
|
calc_results = ijson.items(response_stream, 'nodeResultOuts.item')
|
|
|
|
calc_results = ijson.items(response_stream, 'nodeResultOuts.item')
|
|
|
|
|
|
|
|
|
|
|
|
raise Exception(calc_results)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async for result in calc_results:
|
|
|
|
async for result in calc_results:
|
|
|
|
calc_obj = await create_calc_result_object(
|
|
|
|
calc_obj = await create_calc_result_object(
|
|
|
|
simulation_id, result, available_nodes, eq_update, db_session
|
|
|
|
simulation_id, result, available_nodes, eq_update, db_session
|
|
|
|
@ -843,10 +841,7 @@ async def save_simulation_result(
|
|
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e)
|
|
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# db_session.add_all(calc_objects)
|
|
|
|
db_session.add_all(plot_objects)
|
|
|
|
# db_session.add_all(plot_objects)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
raise Exception(plot_result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
simulation = await get_simulation_by_id(
|
|
|
|
simulation = await get_simulation_by_id(
|
|
|
|
db_session=db_session, simulation_id=simulation_id
|
|
|
|
db_session=db_session, simulation_id=simulation_id
|
|
|
|
@ -1045,3 +1040,44 @@ async def update_simulation(*, db_session: DbSession, simulation_id: UUID, data:
|
|
|
|
query = update(AerosSimulation).where(AerosSimulation.id == simulation_id).values(**data)
|
|
|
|
query = update(AerosSimulation).where(AerosSimulation.id == simulation_id).values(**data)
|
|
|
|
await db_session.execute(query)
|
|
|
|
await db_session.execute(query)
|
|
|
|
await db_session.commit()
|
|
|
|
await db_session.commit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def get_forecast_trending(
|
|
|
|
|
|
|
|
*, db_session: DbSession, time_range: str, limit: int = 12
|
|
|
|
|
|
|
|
) -> list:
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Return EAF/EFOR/SOF/EDH for the last `limit` completed weekly or monthly
|
|
|
|
|
|
|
|
forecast simulations, oldest first (for chronological chart rendering).
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
name_prefix = f"Simulation_{time_range}_"
|
|
|
|
|
|
|
|
plant_node_name = "- TJB - Unit 3 -"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
query = (
|
|
|
|
|
|
|
|
select(AerosSimulation, AerosSimulationCalcResult)
|
|
|
|
|
|
|
|
.join(
|
|
|
|
|
|
|
|
AerosSimulationCalcResult,
|
|
|
|
|
|
|
|
AerosSimulationCalcResult.aeros_simulation_id == AerosSimulation.id,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.join(AerosNode, AerosNode.id == AerosSimulationCalcResult.aeros_node_id)
|
|
|
|
|
|
|
|
.where(AerosSimulation.status == "completed")
|
|
|
|
|
|
|
|
.where(AerosSimulation.simulation_name.like(f"{name_prefix}%"))
|
|
|
|
|
|
|
|
.where(AerosNode.node_name == plant_node_name)
|
|
|
|
|
|
|
|
.order_by(AerosSimulation.completed_at.desc())
|
|
|
|
|
|
|
|
.limit(limit)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = await db_session.execute(query)
|
|
|
|
|
|
|
|
rows = result.all()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"date": sim.completed_at,
|
|
|
|
|
|
|
|
"simulation_id": str(sim.id),
|
|
|
|
|
|
|
|
"simulation_name": sim.simulation_name,
|
|
|
|
|
|
|
|
"eaf": calc.eaf,
|
|
|
|
|
|
|
|
"efor": calc.efor,
|
|
|
|
|
|
|
|
"sof": calc.sof,
|
|
|
|
|
|
|
|
"edh": calc.derating_hours,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for sim, calc in reversed(rows) # oldest → newest for chart x-axis
|
|
|
|
|
|
|
|
]
|
|
|
|
|