diff --git a/.github/workflows/backend_lint_and_test.yml b/.github/workflows/backend_lint_and_test.yml index 39eccff08..53d2209b9 100644 --- a/.github/workflows/backend_lint_and_test.yml +++ b/.github/workflows/backend_lint_and_test.yml @@ -59,3 +59,8 @@ jobs: # We are using severity level 'info' here. - name: Run dotnet format run: dotnet format --severity info --verbosity diagnostic --verify-no-changes --exclude ./api/migrations + + - name: Run csharpier format + run: | + dotnet tool restore + dotnet csharpier --check diff --git a/backend/api/Database/Models/Inspection.cs b/backend/api/Database/Models/Inspection.cs index 97a287191..45b51eaf4 100644 --- a/backend/api/Database/Models/Inspection.cs +++ b/backend/api/Database/Models/Inspection.cs @@ -41,10 +41,10 @@ public Inspection(CustomInspectionQuery inspectionQuery) } // Creates a blank deepcopy of the provided inspection - public Inspection(Inspection copy, InspectionStatus? inspectionStatus = null, bool useEmptyIDs = false) + public Inspection(Inspection copy, InspectionStatus? inspectionStatus = null, bool useEmptyID = false) { - Id = useEmptyIDs ? "" : Guid.NewGuid().ToString(); - IsarTaskId = copy.IsarTaskId; + Id = useEmptyID ? "" : Guid.NewGuid().ToString(); + IsarTaskId = useEmptyID ? "" : copy.IsarTaskId; Status = inspectionStatus ?? copy.Status; InspectionType = copy.InspectionType; VideoDuration = copy.VideoDuration; @@ -133,6 +133,7 @@ public void UpdateStatus(IsarTaskStatus isarStatus) IsarTaskStatus.Successful => InspectionStatus.Successful, IsarTaskStatus.Cancelled => InspectionStatus.Cancelled, IsarTaskStatus.Failed => InspectionStatus.Failed, + IsarTaskStatus.Paused => InspectionStatus.InProgress, _ => throw new ArgumentException( $"ISAR task status '{isarStatus}' not supported for inspection status" diff --git a/backend/api/Database/Models/MissionRun.cs b/backend/api/Database/Models/MissionRun.cs index 46bb84071..9f1440020 100644 --- a/backend/api/Database/Models/MissionRun.cs +++ b/backend/api/Database/Models/MissionRun.cs @@ -153,7 +153,6 @@ public void CalculateEstimatedDuration() const int AssumedXyMetersFromFirst = 20; double distance = 0; - int numberOfTags = 0; var prevPosition = new Position( Tasks.First().RobotPose.Position.X + AssumedXyMetersFromFirst, Tasks.First().RobotPose.Position.Y + AssumedXyMetersFromFirst, @@ -161,7 +160,6 @@ public void CalculateEstimatedDuration() ); foreach (var task in Tasks) { - numberOfTags += 1; var currentPosition = task.RobotPose.Position; distance += Math.Abs(currentPosition.X - prevPosition.X) @@ -170,7 +168,7 @@ public void CalculateEstimatedDuration() } int estimate = (int)( (distance / (RobotVelocity * EfficiencyFactor)) - + (numberOfTags * InspectionTime) + + InspectionTime ); EstimatedDuration = (uint)estimate * 60; } diff --git a/backend/api/Database/Models/MissionTask.cs b/backend/api/Database/Models/MissionTask.cs index c0e666e69..d78fcdcd7 100644 --- a/backend/api/Database/Models/MissionTask.cs +++ b/backend/api/Database/Models/MissionTask.cs @@ -28,7 +28,6 @@ public MissionTask( TaskStatus status = TaskStatus.NotStarted, MissionTaskType type = MissionTaskType.Inspection) { - Inspection = inspection; TagLink = tagLink; TagId = tagId; RobotPose = robotPose; @@ -36,6 +35,7 @@ public MissionTask( TaskOrder = taskOrder; Status = status; Type = type; + if (inspection != null) Inspection = new Inspection(inspection); } public MissionTask(CustomTaskQuery taskQuery) @@ -45,12 +45,15 @@ public MissionTask(CustomTaskQuery taskQuery) RobotPose = taskQuery.RobotPose; TaskOrder = taskQuery.TaskOrder; Status = TaskStatus.NotStarted; - Type = MissionTaskType.ReturnHome; if (taskQuery.Inspection is not null) { Inspection = new Inspection((CustomInspectionQuery)taskQuery.Inspection); Type = MissionTaskType.Inspection; } + else + { + Type = MissionTaskType.ReturnHome; + } } public MissionTask(Pose robotPose, MissionTaskType type) @@ -201,13 +204,8 @@ public static string CalculateHashFromTasks(IList tasks) Id = "", IsarTaskId = "", }; - if (taskCopy.Inspection is not null) - { - taskCopy.Inspection = new Inspection(taskCopy.Inspection, useEmptyIDs: true) - { - IsarTaskId = "" - }; - } + if (taskCopy.Inspection is not null) taskCopy.Inspection = new Inspection(taskCopy.Inspection, useEmptyID: true); + genericTasks.Add(taskCopy); } diff --git a/backend/api/Services/EchoService.cs b/backend/api/Services/EchoService.cs index 359a5937a..559196c6c 100644 --- a/backend/api/Services/EchoService.cs +++ b/backend/api/Services/EchoService.cs @@ -265,12 +265,12 @@ List echoPlantInfoResponse public IList MissionTasksFromEchoTag(EchoTag echoTag) { var inspections = echoTag.Inspections - .Select(inspection => new Inspection( - inspectionType: inspection.InspectionType, - videoDuration: inspection.TimeInSeconds, - inspection.InspectionPoint, - status: InspectionStatus.NotStarted)) - .ToList(); + .Select(inspection => new Inspection( + inspectionType: inspection.InspectionType, + videoDuration: inspection.TimeInSeconds, + inspection.InspectionPoint, + status: InspectionStatus.NotStarted)) + .ToList(); var missionTasks = new List(); @@ -278,17 +278,16 @@ public IList MissionTasksFromEchoTag(EchoTag echoTag) { missionTasks.Add( new MissionTask - ( - inspection: inspection, - tagLink: echoTag.URL, - tagId: echoTag.TagId, - robotPose: echoTag.Pose, - poseId: echoTag.PoseId, - taskOrder: echoTag.PlanOrder, - status: Database.Models.TaskStatus.NotStarted, - type: MissionTaskType.Inspection - )); - + ( + inspection: inspection, + tagLink: echoTag.URL, + tagId: echoTag.TagId, + robotPose: echoTag.Pose, + poseId: echoTag.PoseId, + taskOrder: echoTag.PlanOrder, + status: Database.Models.TaskStatus.NotStarted, + type: MissionTaskType.Inspection + )); } return missionTasks; diff --git a/backend/api/Services/MissionDefinitionService.cs b/backend/api/Services/MissionDefinitionService.cs index 2babc91c1..3027c5295 100644 --- a/backend/api/Services/MissionDefinitionService.cs +++ b/backend/api/Services/MissionDefinitionService.cs @@ -186,7 +186,7 @@ private IQueryable GetMissionDefinitionsWithSubModels(bool re .Include(missionDefinition => missionDefinition.LastSuccessfulRun) .ThenInclude(missionRun => missionRun != null ? missionRun.Tasks : null)! .ThenInclude(missionTask => missionTask.Inspection) - .ThenInclude(inspection => inspection != null ? inspection.InspectionFindings : null)! + .ThenInclude(inspection => inspection != null ? inspection.InspectionFindings : null) .Include(missionDefinition => missionDefinition.Area != null ? missionDefinition.Area.Deck : null) .ThenInclude(deck => deck != null ? deck.DefaultLocalizationPose : null) .ThenInclude(defaultLocalizationPose => defaultLocalizationPose != null ? defaultLocalizationPose.Pose : null) diff --git a/frontend/src/models/Inspection.ts b/frontend/src/models/Inspection.ts index c4d76d349..b19ffdaa1 100644 --- a/frontend/src/models/Inspection.ts +++ b/frontend/src/models/Inspection.ts @@ -9,7 +9,7 @@ export interface Inspection { inspectionTarget: Position videoDuration?: number analysisType?: string - inspectionUrl?: string | null + inspectionUrl?: string startTime?: Date endTime?: Date }