Skip to content

Commit

Permalink
Make areaname nullable in queries
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Aug 4, 2023
1 parent 2b06e7c commit bcc01db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
19 changes: 6 additions & 13 deletions backend/api/Controllers/MissionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,9 @@ [FromBody] ScheduledMissionQuery scheduledMissionQuery
)
.ToList();

var area = await _areaService.ReadByInstallationAndName(scheduledMissionQuery.InstallationCode, scheduledMissionQuery.AreaName);

if (area == null)
{
// This is disabled for now as the Area database is not yet populated
//return NotFound($"Could not find area with name {scheduledMissionQuery.AreaName} in installation {scheduledMissionQuery.InstallationCode}");
}

// TODO: search for if a source with the given type and URL exists, then reuse it
Area? area = null;
if (scheduledMissionQuery.AreaName != null)
area = await _areaService.ReadByInstallationAndName(scheduledMissionQuery.InstallationCode, scheduledMissionQuery.AreaName);

var scheduledMissionDefinition = new MissionDefinition
{
Expand Down Expand Up @@ -454,10 +448,9 @@ [FromBody] CustomMissionQuery customMissionQuery

var missionTasks = customMissionQuery.Tasks.Select(task => new MissionTask(task)).ToList();

var area = await _areaService.ReadByInstallationAndName(customMissionQuery.InstallationCode, customMissionQuery.AreaName);

if (area == null)
return NotFound($"Could not find area with name {customMissionQuery.AreaName} in installation {customMissionQuery.InstallationCode}");
Area? area = null;
if (customMissionQuery.AreaName != null)
area = await _areaService.ReadByInstallationAndName(customMissionQuery.InstallationCode, customMissionQuery.AreaName);

string sourceURL = _customMissionService.UploadSource(missionTasks);

Expand Down
2 changes: 1 addition & 1 deletion backend/api/Controllers/Models/CustomMissionQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public struct CustomMissionQuery

public TimeSpan? InspectionFrequency { get; set; }

public string AreaName { get; set; }
public string? AreaName { get; set; }

public string Name { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion backend/api/Controllers/Models/ScheduledMissionQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public struct ScheduledMissionQuery
public int EchoMissionId { get; set; }
public DateTimeOffset DesiredStartTime { get; set; }
public string InstallationCode { get; set; }
public string AreaName { get; set; }
public string? AreaName { get; set; }
public TimeSpan? InspectionFrequency { get; set; }
}
}

0 comments on commit bcc01db

Please sign in to comment.