From 419495b4cd6206e6f82e6a37d7b465589c93d8d6 Mon Sep 17 00:00:00 2001 From: Nathanael Shim Date: Thu, 14 Mar 2024 12:46:20 -0700 Subject: [PATCH] match getsubmission and listsubmissions --- .../Submissions/Submissions.graphql | 55 +++++++++++- IndicoV2/Submissions/SubmissionsClient.cs | 88 ++++++++++++++----- 2 files changed, 117 insertions(+), 26 deletions(-) diff --git a/IndicoV2.StrawberryShake/Submissions/Submissions.graphql b/IndicoV2.StrawberryShake/Submissions/Submissions.graphql index 49d94de..1878e6c 100644 --- a/IndicoV2.StrawberryShake/Submissions/Submissions.graphql +++ b/IndicoV2.StrawberryShake/Submissions/Submissions.graphql @@ -139,12 +139,63 @@ query GetSubmission($submissionId: Int!) { datasetId workflowId status + createdAt + updatedAt + createdBy + updatedBy + completedAt + errors + filesDeleted + inputFiles { + id + filepath + filename + filetype + submissionId + fileSize + numPages + } inputFile inputFilename resultFile - deleted + outputFiles { + id + filepath + submissionId + componentId + createdAt + } retrieved - errors + autoReview { + id + submissionId + createdAt + createdBy + startedAt + completedAt + rejected + reviewType + notes + } + retries { + id + submissionId + previousErrors + previousStatus + retryErrors + } + reviews { + id + submissionId + createdAt + createdBy + startedAt + completedAt + rejected + reviewType + notes + } + reviewInProgress } } diff --git a/IndicoV2/Submissions/SubmissionsClient.cs b/IndicoV2/Submissions/SubmissionsClient.cs index 0e5048d..1da7114 100644 --- a/IndicoV2/Submissions/SubmissionsClient.cs +++ b/IndicoV2/Submissions/SubmissionsClient.cs @@ -7,6 +7,7 @@ using IndicoV2.CommonModels.Pagination; using IndicoV2.StrawberryShake; using IndicoV2.Submissions.Models; +using IndicoV2.Reviews.Models; using IndicoV2.Storage; using Newtonsoft.Json.Linq; @@ -125,18 +126,7 @@ public async Task GetAsync(int submissionId, CancellationToken canc { throw new NotSupportedException($"Cannot read submission status: {result.Status}"); } - return new Submission - { - Id = result.Id ?? 0, - Status = (Models.SubmissionStatus)result.Status, - DatasetId = result.DatasetId ?? 0, - WorkflowId = result.WorkflowId ?? 0, - InputFile = result.InputFile, - InputFilename = result.InputFilename, - ResultFile = result.ResultFile, - Retrieved = result.Retrieved ?? throw new ArgumentException("Invalid value for retrieved received from call"), - Errors = result.Errors ?? null - }; + return GetSubmissionToSubmission(result); } @@ -147,20 +137,70 @@ public async Task MarkSubmissionAsRetrieved(int submissionId, bool { await _strawberryShakeClient.Submissions().MarkRetrieved(submissionId, retrieved, cancellationToken); var result = await _strawberryShakeClient.Submissions().Get(submissionId, cancellationToken); - return new Submission - { - Id = result.Id ?? 0, - Status = (Models.SubmissionStatus)result.Status, - DatasetId = result.DatasetId ?? 0, - WorkflowId = result.WorkflowId ?? 0, - InputFile = result.InputFile, - InputFilename = result.InputFilename, - ResultFile = result.ResultFile, - Retrieved = result.Retrieved ?? throw new ArgumentException("Invalid value for retrieved received from call"), - Errors = result.Errors ?? null - }; + return GetSubmissionToSubmission(result); } private ISubmission ToSubmissionFromSs(IListSubmissions_Submissions_Submissions submission) => new SubmissionSs(submission); + + private ISubmission GetSubmissionToSubmission(IGetSubmission_Submission result) => new Submission + { + Id = result.Id ?? 0, + Status = (Models.SubmissionStatus)result.Status, + DatasetId = result.DatasetId ?? 0, + WorkflowId = result.WorkflowId ?? 0, + CreatedAt = result.CreatedAt, + UpdatedAt = result.UpdatedAt, + CompletedAt = result.CompletedAt, + FilesDeleted = result.FilesDeleted, + InputFiles = result.InputFiles.Select(inputFile => new SubmissionFile + { + Id = inputFile.Id, + FilePath = inputFile.Filepath, + FileName = inputFile.Filename, + FileType = inputFile.Filetype.ToString(), + SubmissionId = inputFile.SubmissionId, + FileSize = inputFile.FileSize, + NumPages = inputFile.NumPages + }).ToArray(), + InputFile = result.InputFile, + InputFilename = result.InputFilename, + ResultFile = result.ResultFile, + OutputFiles = result.OutputFiles.Select(x => new SubmissionOutput() { }).ToArray(), + Retrieved = result.Retrieved ?? throw new ArgumentException("Invalid value for retrieved received from call"), + AutoReview = result.AutoReview != null ? new Review + { + Id = result.AutoReview.Id, + SubmissionId = result.AutoReview.SubmissionId, + CreatedAt = result.AutoReview.CreatedAt, + CreatedBy = result.AutoReview.CreatedBy, + StartedAt = result.AutoReview.StartedAt, + CompletedAt = result.AutoReview.CompletedAt, + Rejected = result.AutoReview.Rejected, + ReviewType = (Models.ReviewType)result.AutoReview.ReviewType, + Notes = result.AutoReview.Notes, + } : new Review() { }, + Retries = result.Retries.Select(submissionRetry => new SubmissionRetry + { + Id = submissionRetry.Id, + SubmissionId = submissionRetry.SubmissionId, + PreviousErrors = submissionRetry.PreviousErrors, + PreviousStatus = (Models.SubmissionStatus)submissionRetry.PreviousStatus, + RetryErrors = submissionRetry.RetryErrors + }).ToArray(), + Reviews = result.Reviews.Select(review => new Review + { + Id = review.Id, + SubmissionId = review.SubmissionId, + CreatedAt = review.CreatedAt, + CreatedBy = review.CreatedBy, + StartedAt = review.StartedAt, + CompletedAt = review.CompletedAt, + Rejected = review.Rejected, + ReviewType = (Models.ReviewType)review.ReviewType, + Notes = review.Notes, + }).ToArray(), + ReviewInProgress = result.ReviewInProgress, + Errors = result.Errors ?? null + }; } }