-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Area #2015
base: main
Are you sure you want to change the base?
Remove Area #2015
Conversation
🔔 Changes in database folder detected 🔔 |
Will now give warnings on Return to Home missions if they fail becuase we dont have an Area, awaiting Return Home functionallity to be removed aswell. |
1e99cac
to
8029def
Compare
@@ -397,7 +339,6 @@ [.. missionInspectionAreaNames] | |||
Name = missionDefinition.Name, | |||
InspectionFrequency = scheduledMissionQuery.InspectionFrequency, | |||
InstallationCode = scheduledMissionQuery.InstallationCode, | |||
InspectionArea = area.InspectionArea, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this cause the created MissionRun to always have no inspection area?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It either uses a existing missionDefinition or creates a new mission definition here. Since this is the only way new mission definitions are created, and since we don't give the mission definition an inspection area, none of the mission definitions and mission runs will have inspection areas. And since the robots get inspection areas from the first mission they run, they also won't have inspection areas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that is true. Im trying to find a good way of adding inspection area while still removing area. Any suggestions?
if ( | ||
missionRun.Robot.CurrentInspectionArea != null | ||
&& !await localizationService.RobotIsOnSameInspectionAreaAsMission( | ||
missionRun.Robot.Id, | ||
missionRun.InspectionArea!.Id | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should ideally be in a separate commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it should yeah. Also need to remove the localizationService.RobotIsOnSameInspectionAreaAsMission
function perhaps.
List<Area?> missionAreas; | ||
missionAreas = missionTasks | ||
.Where(t => t.TagId != null) | ||
.Select(t => | ||
stidService.GetTagArea(t.TagId!, scheduledMissionQuery.InstallationCode).Result | ||
) | ||
.ToList(); | ||
|
||
var missionInspectionAreaNames = missionAreas | ||
.Where(a => a != null) | ||
.Select(a => a!.InspectionArea.Name) | ||
.Distinct() | ||
.ToList(); | ||
if (missionInspectionAreaNames.Count > 1) | ||
{ | ||
string joinedMissionInspectionAreaNames = string.Join( | ||
", ", | ||
[.. missionInspectionAreaNames] | ||
); | ||
logger.LogWarning( | ||
"Mission {missionDefinition} has tags on more than one inspection area. The inspection areas are: {joinedMissionInspectionAreaNames}.", | ||
missionDefinition.Name, | ||
joinedMissionInspectionAreaNames | ||
); | ||
} | ||
|
||
var sortedAreas = missionAreas | ||
.GroupBy(i => i) | ||
.OrderByDescending(grp => grp.Count()) | ||
.Select(grp => grp.Key); | ||
var area = sortedAreas.First(); | ||
|
||
if (area == null && sortedAreas.Count() > 1) | ||
{ | ||
logger.LogWarning( | ||
"Most common area in mission {missionDefinition} is null. Will use second most common area.", | ||
missionDefinition.Name | ||
); | ||
area = sortedAreas.Skip(1).First(); | ||
} | ||
if (area == null) | ||
{ | ||
logger.LogError( | ||
$"Mission {missionDefinition.Name} doesn't have any tags with valid area." | ||
); | ||
return NotFound($"No area found for mission '{missionDefinition.Name}'."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we perhaps keep this block of code in order to find which inspection area to assign the mission definition? We do not need to have an Area model in the database to do this, as it fetches them from an external API (STID). We do however need the inspection area to have an understanding of STID areas though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally we planned InspectionAreas to be a list or graph of Areas. Could we potentially store the references to STID areas as a list in InspectionAreas still, but without storing them as Area objects, for instance by only storing the area name?
4d9b2be
to
1c92591
Compare
We could potentially link this issue: #1840, but that will depend on how we solve the inspection area issue |
1c92591
to
ce5b9d9
Compare
Rest of work to be done documented in: |
ce5b9d9
to
3bf85c3
Compare
Done once per asset (possible with multiple inspection areas per asset) (not per mission) awaiting
|
Ready for review checklist: