Skip to content

Commit

Permalink
Fix rerunning failed tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Jul 18, 2024
1 parent bba48ae commit 33746dd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
12 changes: 11 additions & 1 deletion backend/api.test/Mocks/CustomMissionServiceMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ public Task<string> UploadSource(List<MissionTask> tasks)

public string CalculateHashFromTasks(IList<MissionTask> tasks)
{
IList<MissionTask> genericTasks = tasks.Select(task => new MissionTask(task)).ToList();
var genericTasks = new List<MissionTask>();
foreach (var task in tasks)
{
var taskCopy = new MissionTask(task)
{
Id = "",
IsarTaskId = ""
};
taskCopy.Inspections = taskCopy.Inspections.Select(i => new Inspection(i, useEmptyIDs: true)).ToList();
genericTasks.Add(taskCopy);
}

string json = JsonSerializer.Serialize(genericTasks);
byte[] hash = SHA256.HashData(Encoding.UTF8.GetBytes(json));
Expand Down
6 changes: 3 additions & 3 deletions backend/api/Database/Models/Inspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public Inspection(CustomInspectionQuery inspectionQuery)
}

// Creates a blank deepcopy of the provided inspection
public Inspection(Inspection copy, InspectionStatus? inspectionStatus = null)
public Inspection(Inspection copy, InspectionStatus? inspectionStatus = null, bool useEmptyIDs = false)
{
Id = "";
IsarStepId = "";
Id = useEmptyIDs ? "" : Guid.NewGuid().ToString();
IsarStepId = useEmptyIDs ? "" : Guid.NewGuid().ToString();
Status = inspectionStatus ?? copy.Status;
InspectionType = copy.InspectionType;
VideoDuration = copy.VideoDuration;
Expand Down
4 changes: 2 additions & 2 deletions backend/api/Database/Models/MissionTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public MissionTask(Pose robotPose, MissionTaskType type)
}
}

// Creates a blank deepcopy of the provided task
// Creates a copy of the provided task
public MissionTask(MissionTask copy, TaskStatus? status = null)
{
TaskOrder = copy.TaskOrder;
TagId = copy.TagId;
IsarTaskId = status == null ? "" : null;
IsarTaskId = Guid.NewGuid().ToString();
Description = copy.Description;
EchoTagLink = copy.EchoTagLink;
RobotPose = new Pose(copy.RobotPose);
Expand Down
1 change: 1 addition & 0 deletions backend/api/Services/CustomMissionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public string CalculateHashFromTasks(IList<MissionTask> tasks)
Id = "",
IsarTaskId = ""
};
taskCopy.Inspections = taskCopy.Inspections.Select(i => new Inspection(i, useEmptyIDs: true)).ToList();
genericTasks.Add(taskCopy);
}

Expand Down

0 comments on commit 33746dd

Please sign in to comment.