From d3ac1e2fdd4f1f0e2473ad47cd7fce912c0c984c Mon Sep 17 00:00:00 2001 From: Nathanael Shim Date: Wed, 13 Mar 2024 08:31:59 -0700 Subject: [PATCH 1/5] update dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index adfcd84..0595021 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 +WORKDIR indico-client-csharp COPY . ./ RUN dotnet restore RUN dotnet build --no-restore -c Release From 80b7c7d71a1f6713eeab65d6a7e4fcdfff627506 Mon Sep 17 00:00:00 2001 From: Nathanael Shim Date: Wed, 13 Mar 2024 08:51:03 -0700 Subject: [PATCH 2/5] update assembly version --- IndicoV2/IndicoV2.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IndicoV2/IndicoV2.csproj b/IndicoV2/IndicoV2.csproj index 49c5beb..4228ca4 100644 --- a/IndicoV2/IndicoV2.csproj +++ b/IndicoV2/IndicoV2.csproj @@ -8,7 +8,7 @@ - 2.0.1 + 6.0.0 $(AssemblyVersion)-preview.$([System.DateTime]::UtcNow.ToString(yyMMddHHmm)) $(TargetsForTfmSpecificBuildOutput);IncludeP2POutput From bc56d6266d0cf7ef69d0a33ca930534081bd5b00 Mon Sep 17 00:00:00 2001 From: Nathanael Shim Date: Wed, 13 Mar 2024 13:07:11 -0700 Subject: [PATCH 3/5] fix error with and filter --- IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs b/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs index 4c93c54..e06e704 100644 --- a/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs +++ b/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs @@ -22,7 +22,7 @@ public static ssSubmissionFilter ConvertToSs(this IFilter filter) { ssFilter.Filetype = submissionFilter.FileType.Select(x => (FileType)Enum.Parse(typeof(FileType), x)).ToList(); } - if (string.IsNullOrEmpty(submissionFilter.InputFilename)) + if (!string.IsNullOrEmpty(submissionFilter.InputFilename)) { ssFilter.InputFilename = submissionFilter.InputFilename; } @@ -71,6 +71,7 @@ public static ssSubmissionFilter ConvertToSs(this IFilter filter) } else if (filter is AndFilter andfilter) { + Console.WriteLine("and"); return new ssSubmissionFilter() { AND = andfilter.And.Select(a => a.ConvertToSs()).ToList() @@ -79,6 +80,7 @@ public static ssSubmissionFilter ConvertToSs(this IFilter filter) } else if (filter is OrFilter orFilter) { + Console.WriteLine("or"); return new ssSubmissionFilter() { OR = orFilter.Or.Select(a => a.ConvertToSs()).ToList() From 3f61ede716463bcda023eab9bd0905faafeaf3cb Mon Sep 17 00:00:00 2001 From: Nathanael Shim Date: Wed, 13 Mar 2024 13:17:13 -0700 Subject: [PATCH 4/5] update submission filter examples and remove console logs --- Examples/SubmissionFilterExample/Program.cs | 91 ++++++++++++++----- .../Submissions/Models/FilterConverter.cs | 2 - 2 files changed, 69 insertions(+), 24 deletions(-) diff --git a/Examples/SubmissionFilterExample/Program.cs b/Examples/SubmissionFilterExample/Program.cs index 05e4404..93a20dd 100644 --- a/Examples/SubmissionFilterExample/Program.cs +++ b/Examples/SubmissionFilterExample/Program.cs @@ -23,10 +23,10 @@ public static async Task Main() var workflowIds = new List() { 3106 }; // Example 1 - // List all submissions that are complete or failed - var orFilter = new OrFilter + // List all submissions that are COMPLETE and not retrieved + var andFilter = new AndFilter { - Or = new List + And = new List { new SubmissionFilter { @@ -34,40 +34,69 @@ public static async Task Main() }, new SubmissionFilter { - Status = SubmissionStatus.FAILED, + Retrieved = false, } } }; - var submissions = await submissionClient.ListAsync(submissionIds, workflowIds, orFilter, limit: 10); + submissions = await submissionClient.ListAsync(submissionIds, workflowIds, andFilter, limit: 10); Console.WriteLine(submissions); // Example 2 - // List all submissions that are COMPLETE and FAILED - var andFilter = new AndFilter + // List all submissions that are complete and not retrieved or failed and not retrieved + var orFilter = new OrFilter { - And = new List + Or = new List { - new SubmissionFilter + new AndFilter { - Status = SubmissionStatus.COMPLETE, + And = new List + { + new SubmissionFilter + { + Status = SubmissionStatus.COMPLETE, + }, + new SubmissionFilter + { + Retrieved = false, + } + } }, - new SubmissionFilter + new AndFilter { - Status = SubmissionStatus.FAILED, + And = new List + { + new SubmissionFilter + { + Status = SubmissionStatus.FAILED, + }, + new SubmissionFilter + { + Retrieved = false, + } + } } } }; - submissions = await submissionClient.ListAsync(submissionIds, workflowIds, andFilter, limit: 10); + var submissions = await submissionClient.ListAsync(submissionIds, workflowIds, orFilter, limit: 10); Console.WriteLine(submissions); // Example 3 // List all submissions that are retrieved and have a filename that contains 'property' - var subFilter = new SubmissionFilter + var subFilter = new AndFilter { - Retrieved = true, - InputFilename = "property" + And = new List + { + new SubmissionFilter + { + Retrieved = true, + }, + new SubmissionFilter + { + InputFilename = "property", + } + } }; submissions = await submissionClient.ListAsync(submissionIds, workflowIds, subFilter, limit: 10); @@ -80,10 +109,19 @@ public static async Task Main() From = "2022-01-01", To = DateTime.Now.ToString("yyyy-MM-dd") }; - subFilter = new SubmissionFilter + subFilter = new AndFilter { - CreatedAt = dateRangeFilter, - UpdatedAt = dateRangeFilter + And = new List + { + new SubmissionFilter + { + CreatedAt = dateRangeFilter, + }, + new SubmissionFilter + { + UpdatedAt = dateRangeFilter, + }, + } }; submissions = await submissionClient.ListAsync(submissionIds, workflowIds, subFilter, limit: 10); @@ -91,10 +129,19 @@ public static async Task Main() // Example 5 // List all submissions that are not in progress of being reviewed and are completed - subFilter = new SubmissionFilter + subFilter = new AndFilter { - Status = SubmissionStatus.COMPLETE, - ReviewInProgress = false + And = new List + { + new SubmissionFilter + { + Status = SubmissionStatus.COMPLETE, + }, + new SubmissionFilter + { + ReviewInProgress = false, + } + } }; submissions = await submissionClient.ListAsync(submissionIds, workflowIds, subFilter, limit: 10); diff --git a/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs b/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs index e06e704..b229395 100644 --- a/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs +++ b/IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs @@ -71,7 +71,6 @@ public static ssSubmissionFilter ConvertToSs(this IFilter filter) } else if (filter is AndFilter andfilter) { - Console.WriteLine("and"); return new ssSubmissionFilter() { AND = andfilter.And.Select(a => a.ConvertToSs()).ToList() @@ -80,7 +79,6 @@ public static ssSubmissionFilter ConvertToSs(this IFilter filter) } else if (filter is OrFilter orFilter) { - Console.WriteLine("or"); return new ssSubmissionFilter() { OR = orFilter.Or.Select(a => a.ConvertToSs()).ToList() From 0820ecfdfb24616fe23af2b3931327813b002df5 Mon Sep 17 00:00:00 2001 From: Nathanael Shim Date: Wed, 13 Mar 2024 13:23:20 -0700 Subject: [PATCH 5/5] add test case to list submissions --- .../Submissions/SubmissionClientTests.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/IndicoV2.IntegrationTests/Submissions/SubmissionClientTests.cs b/IndicoV2.IntegrationTests/Submissions/SubmissionClientTests.cs index 9edb84a..5cc1f73 100644 --- a/IndicoV2.IntegrationTests/Submissions/SubmissionClientTests.cs +++ b/IndicoV2.IntegrationTests/Submissions/SubmissionClientTests.cs @@ -315,6 +315,62 @@ public async Task ListSubmissions_SubmissionFilterUpdatedAt_ShouldFetchSubmissio } + [Test] + public async Task ListSubmissions_SubmissionOrAndFilter_ShouldFetchSubmissions() + { + // Arrange + var listData = await _dataHelper.Submissions().ListAnyAsync(_workflowId); + + var filters = new OrFilter + { + Or = new List + { + new AndFilter + { + And = new List + { + new SubmissionFilter + { + Status = SubmissionStatus.COMPLETE, + }, + new SubmissionFilter + { + Retrieved = false, + } + } + }, + new AndFilter + { + And = new List + { + new SubmissionFilter + { + Status = SubmissionStatus.FAILED, + }, + new SubmissionFilter + { + Retrieved = false, + } + } + } + } + }; + // Act + var submissions = await _submissionsClient.ListAsync(null, new List { listData.workflowId }, filters, 0, 10); + + submissions.Should().NotBeNull(); + submissions.PageInfo.Should().NotBeNull(); + submissions.Data.Should().NotBeNull(); + foreach (var submission in submissions.Data) + { + submission.Id.Should().BeGreaterThan(0); + submission.Status.Should().BeOfType(); + submission.Status.Should().Match(status => status == SubmissionStatus.COMPLETE || status == SubmissionStatus.FAILED); + submission.Retrieved.Should().BeFalse(); + } + } + + [Test] public async Task GenerateSubmissionResultAsync_ShouldReturnJob()