Skip to content
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

Allow missions where most tags don't have area #1844

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions backend/api/Controllers/MissionSchedulingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,18 @@ [FromBody] ScheduledMissionQuery scheduledMissionQuery
logger.LogWarning($"Mission {missionDefinition.Name} has tags on more than one deck. The decks are: {joinedMissionDeckNames}.");
}

Area? area = null;
area = missionAreas.GroupBy(i => i).OrderByDescending(grp => grp.Count()).Select(grp => grp.Key).First();
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.Name} is null. Will use second most common area.");
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}'.");
}

Expand Down
11 changes: 9 additions & 2 deletions backend/api/Services/EchoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,18 @@ public async Task<List<MissionTask>> GetTasksForMission(string missionSourceId)
logger.LogWarning($"Mission {echoMission.Name} has tags on more than one deck. The decks are: {joinedMissionDeckNames}.");
}

Area? area = null;
area = missionAreas.GroupBy(i => i).OrderByDescending(grp => grp.Count()).Select(grp => grp.Key).First();
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 {echoMission.Name} is null. Will use second most common area.");
area = sortedAreas.Skip(1).First();

}
if (area == null)
{
logger.LogError($"Mission {echoMission.Name} doesn't have any tags with valid area.");
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion backend/api/Services/StidService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class StidService(ILogger<StidService> logger, IDownstreamApi stidApi, IA
if (stidTagAreaResponse.LocationCode == null)
{
string errorMessage = $"Could not get area name from STID for tag {tag}";
logger.LogError("{Message}", errorMessage);
logger.LogDebug("{Message}", errorMessage);
return null;
}

Expand Down
Loading