From 6713cc7b2288bc34d70a57c2fcbd45ba92bd983a Mon Sep 17 00:00:00 2001 From: Cizz22 Date: Mon, 13 Apr 2026 14:00:49 +0700 Subject: [PATCH] fix: update simulation forecast window logic and include node relationship loading in trip query --- src/aeros_simulation/router.py | 4 ++-- src/dashboard_model/service.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/aeros_simulation/router.py b/src/aeros_simulation/router.py index 8154ffd..c4d32f5 100644 --- a/src/aeros_simulation/router.py +++ b/src/aeros_simulation/router.py @@ -533,8 +533,8 @@ async def get_forecast_eaf( # 4. Define Forecast Window duration = 168 if time_range == "weekly" else 720 - start_date = oh_date + timedelta(hours=offset_hours) - end_date = start_date + timedelta(hours=duration) + start_date = oh_date + end_date = now + timedelta(hours=duration) project = await get_project(db_session=db_session) # 5. Create Simulation Request diff --git a/src/dashboard_model/service.py b/src/dashboard_model/service.py index 2a91eec..8f84f6b 100644 --- a/src/dashboard_model/service.py +++ b/src/dashboard_model/service.py @@ -180,7 +180,7 @@ async def get_latest_sim_results_by_pattern(db_session: DbSession, pattern: str) trip_query = select(AerosSimulationCalcResult).join(AerosNode).where( AerosSimulationCalcResult.aeros_simulation_id == simulation.id, AerosNode.node_type == 'RegularNode' - ).order_by(AerosSimulationCalcResult.num_events.desc()).limit(5) + ).options(selectinload(AerosSimulationCalcResult.aeros_node)).order_by(AerosSimulationCalcResult.num_events.desc()).limit(5) trip_res_exec = await db_session.execute(trip_query) trip_results = trip_res_exec.scalars().all()