From 786d57e21636f9e2901078133e5035edd7669c10 Mon Sep 17 00:00:00 2001 From: John-Vaughan <114492829+John-Vaughan@users.noreply.github.com> Date: Fri, 26 Apr 2024 11:32:40 +0100 Subject: [PATCH] fix(tre api) fixes addi egrees (#654) --- src/TRE-API/Services/SubmissionHelper.cs | 28 +++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/TRE-API/Services/SubmissionHelper.cs b/src/TRE-API/Services/SubmissionHelper.cs index e365efb03..b8984c08d 100644 --- a/src/TRE-API/Services/SubmissionHelper.cs +++ b/src/TRE-API/Services/SubmissionHelper.cs @@ -16,6 +16,7 @@ using TRE_API.Repositories.DbContexts; using TRE_API.Services.SignalR; using static TRE_API.Controllers.SubmissionController; +using TRE_API.Models; namespace TRE_API.Services @@ -44,7 +45,9 @@ public class SubmissionHelper: ISubmissionHelper private readonly IBus _rabbit; private readonly IDataEgressClientWithoutTokenHelper _dataEgressHelper; private readonly IMinioTreHelper _minioTreHelper; - + private readonly AgentSettings _agentSettings; + + public string _hutchDbServer { get; set; } public string _hutchDbPort { get; set; } @@ -59,7 +62,9 @@ public SubmissionHelper(ISignalRService signalRService, IConfiguration config, MinioTRESettings minioTreSettings, IDataEgressClientWithoutTokenHelper dataEgressHelper, - IMinioTreHelper minioTreHelper) + IMinioTreHelper minioTreHelper, + AgentSettings agentSettings + ) { _dareHelper = helper; @@ -73,6 +78,7 @@ public SubmissionHelper(ISignalRService signalRService, _dataEgressHelper = dataEgressHelper; _minioTreHelper = minioTreHelper; + _agentSettings = agentSettings; } public OutputBucketInfo GetOutputBucketGutsSub(string subId, bool hostnameonly) @@ -81,14 +87,24 @@ public OutputBucketInfo GetOutputBucketGutsSub(string subId, bool hostnameonly) { var submission = _dareHelper .CallAPIWithoutModel($"/api/Submission/GetASubmission/{subId}") - .Result; + .Result; + string? outputBucket = ""; - var bucket = _dbContext.Projects + if (_agentSettings.UseTESK == false) + { + outputBucket = _dbContext.Projects .Where(x => x.SubmissionProjectId == submission.Project.Id) - .Select(x => x.OutputBucketTre); + .Select(x => x.OutputBucketTre).FirstOrDefault(); + } + else + { + outputBucket = _dbContext.Projects + .Where(x => x.SubmissionProjectId == submission.Project.Id) + .Select(x => x.OutputBucketSub).FirstOrDefault(); + } - var outputBucket = bucket.FirstOrDefault(); + bool secure = !_minioTreSettings.Url.ToLower().StartsWith("http://"); return new OutputBucketInfo()