From cbc6e6e695dd7387cc5a8115016ea99c3bf82e1a Mon Sep 17 00:00:00 2001 From: Eddasol Date: Wed, 15 Jan 2025 09:52:27 +0100 Subject: [PATCH] Try to assign map to mission if no existing map --- .../api/Controllers/MissionSchedulingController.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/api/Controllers/MissionSchedulingController.cs b/backend/api/Controllers/MissionSchedulingController.cs index 178a2b3a..f07eba8d 100644 --- a/backend/api/Controllers/MissionSchedulingController.cs +++ b/backend/api/Controllers/MissionSchedulingController.cs @@ -206,6 +206,19 @@ await localizationService.EnsureRobotIsOnSameInstallationAsMission( InspectionArea = missionDefinition.InspectionArea, }; + if (missionDefinition.Map == null) + { + var newMap = await mapService.ChooseMapFromMissionRunTasks(missionRun); + if (newMap != null) + { + logger.LogInformation( + $"Assigned map {newMap.MapName} to mission definition with id {missionDefinition.Id}" + ); + missionDefinition.Map = newMap; + await missionDefinitionService.Update(missionDefinition); + } + } + if (missionRun.Tasks.Any()) { missionRun.CalculateEstimatedDuration();