feat: include overhaul interval calculation in simulation configuration using next overhaul date master data

main
Cizz22 3 months ago
parent dd99f1874a
commit a58e27e973

@ -514,6 +514,7 @@ async def get_forecast_eaf(
# 2. Determine Last Overhaul Date from Master Data
oh_record = await _get_or_create_master_data(db_session, "Last Overhaul Date", 0)
next_oh = await _get_or_create_master_data(db_session, "Next Overhaul Date", 0)
# If not set, use a fallback (e.g., start of current year)
if not oh_record.value_string:
@ -524,9 +525,11 @@ async def get_forecast_eaf(
try:
# Ensure oh_date is naive
oh_date = datetime.fromisoformat(oh_date_str).replace(tzinfo=None)
next_oh_date = datetime.fromisoformat(next_oh.value_string).replace(tzinfo=None)
except Exception:
oh_date = datetime(now.year, 1, 1).replace(tzinfo=None)
oh_interval = hours_between(oh_date, next_oh_date)
duration = 168 if time_range == "weekly" else 720
end_date = now + timedelta(hours=duration)
duration_simulation = hours_between(oh_date, end_date)
@ -541,7 +544,8 @@ async def get_forecast_eaf(
OffSet=0,
SimSeed=1,
SimNumRun=1,
IsDefault=False
IsDefault=False,
OverhaulInterval=oh_interval
)
# 6. Initialize Simulation in DB

Loading…
Cancel
Save