From ac36b4df074e93325c675672e0a9a3cbe49ffa0e Mon Sep 17 00:00:00 2001 From: oysand Date: Wed, 27 Nov 2024 13:36:58 +0100 Subject: [PATCH] Remove redundant check The current mission id is set to null in onIsarStatusUpdate if the robot status is available before triggering onRobotAvailable, so we don't need to check if it's null in onRobotAvailable. --- backend/api/EventHandlers/MissionEventHandler.cs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/backend/api/EventHandlers/MissionEventHandler.cs b/backend/api/EventHandlers/MissionEventHandler.cs index 28d55ee96..1fa0050e1 100644 --- a/backend/api/EventHandlers/MissionEventHandler.cs +++ b/backend/api/EventHandlers/MissionEventHandler.cs @@ -111,21 +111,6 @@ private async void OnRobotAvailable(object? sender, RobotAvailableEventArgs e) return; } - if (robot.CurrentMissionId != null) - { - var stuckMission = await MissionService.ReadById(robot.CurrentMissionId!, readOnly: true); - if (stuckMission == null) - { - _logger.LogError("MissionRun with ID: {MissionId} was not found in the database", robot.CurrentMissionId); - return; - } - if (stuckMission.Status == MissionStatus.Ongoing || stuckMission.Status == MissionStatus.Paused) - { - _logger.LogError("Ongoing/paused mission with ID: ${MissionId} is not being run in ISAR", robot.CurrentMissionId); - await MissionService.SetMissionRunToFailed(stuckMission.Id, "Mission failed due to issue with ISAR"); - } - } - _startMissionSemaphore.WaitOne(); try { await MissionScheduling.StartNextMissionRunIfSystemIsAvailable(robot.Id); } catch (MissionRunNotFoundException) { return; }