Skip to content

Commit

Permalink
match getsubmission and listsubmissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathanael Shim authored and Nathanael Shim committed Mar 14, 2024
1 parent 26db775 commit 419495b
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 26 deletions.
55 changes: 53 additions & 2 deletions IndicoV2.StrawberryShake/Submissions/Submissions.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
88 changes: 64 additions & 24 deletions IndicoV2/Submissions/SubmissionsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -125,18 +126,7 @@ public async Task<ISubmission> 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);
}


Expand All @@ -147,20 +137,70 @@ public async Task<ISubmission> 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
};
}
}

0 comments on commit 419495b

Please sign in to comment.