Skip to content

Commit

Permalink
Add support for using both echo and custom mission
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddasol committed Sep 20, 2024
1 parent 7fa07c5 commit f215ee9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
37 changes: 37 additions & 0 deletions backend/api/Services/MissionLoaders/EchoAndCustomMissionLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Api.Controllers.Models;
using Api.Database.Models;
namespace Api.Services.MissionLoaders
{
public class EchoAndCustomMissionLoader(
IEchoService echoService,
ISourceService sourceService) : IMissionLoader
{
public async Task<IQueryable<MissionDefinition>> GetAvailableMissions(string? installationCode)
{
return await echoService.GetAvailableMissions(installationCode);
}

public async Task<MissionDefinition?> GetMissionById(string sourceMissionId)
{
return await echoService.GetMissionById(sourceMissionId);
}

public async Task<List<MissionTask>> GetTasksForMission(string missionSourceId)
{
var customMissionTasks = await sourceService.GetMissionTasksFromSourceId(missionSourceId);
if (customMissionTasks != null)
{
return customMissionTasks;
}
else
{
return await echoService.GetTasksForMission(missionSourceId);
}
}

public async Task<List<PlantInfo>> GetPlantInfos()
{
return await echoService.GetPlantInfos();
}
}
}
2 changes: 2 additions & 0 deletions backend/api/Services/SourceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public interface ISourceService

public abstract Task<Source> CreateSourceIfDoesNotExist(List<MissionTask> tasks, bool readOnly = true);

public abstract Task<List<MissionTask>?> GetMissionTasksFromSourceId(string id);

public abstract Task<Source?> Delete(string id);

public void DetachTracking(Source source);
Expand Down
2 changes: 1 addition & 1 deletion backend/api/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"ConnectionString": ""
},
"MissionLoader": {
"FileName": "Api.Services.MissionLoaders.EchoMissionLoader"
"FileName": "Api.Services.MissionLoaders.EchoAndCustomMissionLoader"
},
"KeyVault": {
"UseKeyVault": true
Expand Down

0 comments on commit f215ee9

Please sign in to comment.