Skip to content

Commit

Permalink
Fix incorrect updating of missionStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Jan 21, 2025
1 parent 8a20eb1 commit 18b8aa7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
8 changes: 8 additions & 0 deletions backend/api/EventHandlers/MissionEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ private async void OnMissionRunCreated(object? sender, MissionRunCreatedEventArg

private async void OnRobotAvailable(object? sender, RobotAvailableEventArgs e)
{
if (e.Robot.Status != RobotStatus.Available)
{
_logger.LogWarning(
"OnRobotAvailable was triggered while robot was {robotStatus}",
e.Robot.Status
);
return;
}
_startMissionSemaphore.WaitOne();
try
{
Expand Down
2 changes: 1 addition & 1 deletion backend/api/EventHandlers/MqttEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ await MissionRunService.UpdateMissionRunStatusByIsarMissionId(
if (updatedFlotillaMissionRun.MissionId == null)
{
_logger.LogInformation(
"Mission run {missionRunId} does not have a mission definition assosiated with it",
"Mission run {missionRunId} does not have a mission definition associated with it",
updatedFlotillaMissionRun.Id
);
return;
Expand Down
17 changes: 7 additions & 10 deletions backend/api/Services/MissionRunService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public bool IncludesUnsupportedInspectionType(MissionRun missionRun)
);
}

public async Task<MissionRun> Update(MissionRun missionRun)
public async Task Update(MissionRun missionRun)
{
if (missionRun.Robot is not null)
{
Expand All @@ -320,7 +320,6 @@ public async Task<MissionRun> Update(MissionRun missionRun)
missionRun != null ? new MissionRunResponse(missionRun) : null
);
DetachTracking(context, missionRun!);
return entry.Entity;
}

public async Task<MissionRun?> Delete(string id)
Expand Down Expand Up @@ -664,11 +663,7 @@ MissionStatus missionStatus

missionRun.Status = missionStatus;

missionRun = await UpdateMissionRunProperty(
missionRun.Id,
"MissionStatus",
missionStatus
);
missionRun = await UpdateMissionRunProperty(missionRun.Id, "Status", missionStatus);

if (missionRun.Status == MissionStatus.Failed)
{
Expand Down Expand Up @@ -716,7 +711,7 @@ public async Task<MissionRun> UpdateMissionRunProperty(

try
{
missionRun = await Update(missionRun);
await Update(missionRun);
}
catch (InvalidOperationException e)
{
Expand Down Expand Up @@ -778,7 +773,8 @@ await ReadById(missionRunId, readOnly: true)
task.Inspection.Status = InspectionStatus.Failed;
}
}
return await Update(missionRun);
await Update(missionRun);
return missionRun;
}

public void DetachTracking(FlotillaDbContext context, MissionRun missionRun)
Expand Down Expand Up @@ -818,7 +814,8 @@ await ReadById(missionRunId, readOnly: true)
var task = missionRun.GetTaskByIsarId(isarTask.IsarTaskId);
task?.UpdateWithIsarInfo(isarTask);
}
return await Update(missionRun);
await Update(missionRun);
return missionRun;
}
}
}

0 comments on commit 18b8aa7

Please sign in to comment.