Skip to content

Commit

Permalink
Remove unnecessary keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Jul 27, 2023
1 parent c025fec commit a91e614
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 21 deletions.
5 changes: 1 addition & 4 deletions backend/api.test/EndpointTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,8 @@ public async Task SafePositionTest()
{
// Arrange - Add Safe Position
string testInstallation = "testInstallation";
string testPlant = "testPlant";
string testDeck = "testDeck";
string testArea = "testArea";
string addSafePositionUrl = $"/areas/{testInstallation}/{testPlant}/{testDeck}/{testArea}/safe-position";
string addSafePositionUrl = $"/areas/{testInstallation}/{testArea}/safe-position";
var testPosition = new Position
{
X = 1,
Expand Down Expand Up @@ -473,7 +471,6 @@ public async Task GetMapMetadata()
string url = $"/areas/{areaId}/map-metadata";
var response = await _client.GetAsync(url);
Assert.Equal(inputOutputPairs[input], response.StatusCode);

}
}
}
Expand Down
13 changes: 4 additions & 9 deletions backend/api/Controllers/AreaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,19 @@ public async Task<ActionResult<AreaResponse>> Create([FromBody] CreateAreaQuery
/// </remarks>
[HttpPost]
[Authorize(Roles = Role.Admin)]
[Route("{installationCode}/{plantCode}/{deckName}/{areaName}/safe-position")]
[Route("{installationCode}/{areaName}/safe-position")]
[ProducesResponseType(typeof(AreaResponse), StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<AreaResponse>> AddSafePosition(
[FromRoute] string installationCode,
[FromRoute] string plantCode,
[FromRoute] string deckName,
[FromRoute] string areaName,
[FromBody] Pose safePosition
)
{
_logger.LogInformation(@"Adding new safe position to {Installation}, {Plant},
{Deck}, {Area}", installationCode, plantCode, deckName, areaName);
_logger.LogInformation(@"Adding new safe position to {Installation}, {Area}", installationCode, areaName);
try
{
var area = await _areaService.AddSafePosition(installationCode, areaName, new SafePosition(safePosition));
Expand All @@ -129,10 +126,8 @@ [FromBody] Pose safePosition
}
else
{
_logger.LogInformation(@"No area with installation {installationCode}, plant {plantCode},
deck {deckName} and name {areaName} could be found.", installationCode, plantCode, deckName, areaName);
return NotFound(@$"No area with installation {installationCode}, plant {plantCode},
deck {deckName} and name {areaName} could be found.");
_logger.LogInformation(@"No area with installation {installationCode} and name {areaName} could be found.", installationCode, areaName);
return NotFound(@$"No area with installation {installationCode} and name {areaName} could be found.");
}
}
catch (Exception e)
Expand Down
2 changes: 1 addition & 1 deletion backend/api/Controllers/MissionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ [FromBody] CustomMissionQuery customMissionQuery
if (area == null)
return NotFound($"Could not find area with name {customMissionQuery.AreaName} in installation {customMissionQuery.InstallationCode}");

string sourceURL = await _customMissionService.UploadSource(missionTasks);
string sourceURL = _customMissionService.UploadSource(missionTasks);

var customMissionDefinition = new MissionDefinition
{
Expand Down
2 changes: 1 addition & 1 deletion backend/api/Controllers/PlantController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public async Task<ActionResult<Plant>> Create([FromBody] CreatePlantQuery plant)
var existingPlant = await _plantService.ReadByInstallationAndName(existingInstallation, plant.PlantCode);
if (existingPlant != null)
{
_logger.LogInformation("An plant for given name and plant already exists");
_logger.LogInformation("A plant for given name and plant already exists");
return BadRequest($"Plant already exists");
}

Expand Down
5 changes: 1 addition & 4 deletions backend/api/Services/AreaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,8 @@ public async Task<IEnumerable<Area>> ReadByInstallation(string installationCode)
.Include(a => a.Plant).Include(a => a.Deck).ToListAsync();
}

public async Task<Area?> ReadByInstallationAndPlantAndDeckAndName(Installation? installation, Plant? plant, Deck? deck, string areaName)
public async Task<Area?> ReadByInstallationAndPlantAndDeckAndName(Installation installation, Plant plant, Deck deck, string areaName)
{
if (installation == null || plant == null || deck == null)
return null;

return await _context.Areas.Where(a =>
a.Deck.Id.Equals(deck.Id) &&
a.Plant.Id.Equals(plant.Id) &&
Expand Down
4 changes: 2 additions & 2 deletions backend/api/Services/CustomMissionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Api.Services

public interface ICustomMissionService
{
Task<string> UploadSource(List<MissionTask> tasks);
string UploadSource(List<MissionTask> tasks);
Task<List<MissionTask>?> GetMissionTasksFromMissionId(string id);
}

Expand All @@ -25,7 +25,7 @@ public CustomMissionService(IOptions<StorageOptions> storageOptions, IBlobServic
_blobService = blobService;
}

public async Task<string> UploadSource(List<MissionTask> tasks)
public string UploadSource(List<MissionTask> tasks)
{
string json = JsonSerializer.Serialize(tasks);
string id = Guid.NewGuid().ToString();
Expand Down

0 comments on commit a91e614

Please sign in to comment.