diff --git a/backend/api.test/Mocks/CustomMissionServiceMock.cs b/backend/api.test/Mocks/CustomMissionServiceMock.cs index b95831901..d76ead6fa 100644 --- a/backend/api.test/Mocks/CustomMissionServiceMock.cs +++ b/backend/api.test/Mocks/CustomMissionServiceMock.cs @@ -37,7 +37,17 @@ public Task UploadSource(List tasks) public string CalculateHashFromTasks(IList tasks) { - IList genericTasks = tasks.Select(task => new MissionTask(task)).ToList(); + var genericTasks = new List(); + 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)); diff --git a/backend/api/Database/Models/Inspection.cs b/backend/api/Database/Models/Inspection.cs index 52ec9a3fc..2bedba0d6 100644 --- a/backend/api/Database/Models/Inspection.cs +++ b/backend/api/Database/Models/Inspection.cs @@ -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; diff --git a/backend/api/Database/Models/MissionTask.cs b/backend/api/Database/Models/MissionTask.cs index b483a62e8..f7e486ce2 100644 --- a/backend/api/Database/Models/MissionTask.cs +++ b/backend/api/Database/Models/MissionTask.cs @@ -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); diff --git a/backend/api/Services/CustomMissionService.cs b/backend/api/Services/CustomMissionService.cs index 49f36e05d..6a696b00b 100644 --- a/backend/api/Services/CustomMissionService.cs +++ b/backend/api/Services/CustomMissionService.cs @@ -59,6 +59,7 @@ public string CalculateHashFromTasks(IList tasks) Id = "", IsarTaskId = "" }; + taskCopy.Inspections = taskCopy.Inspections.Select(i => new Inspection(i, useEmptyIDs: true)).ToList(); genericTasks.Add(taskCopy); }