Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEV-11445] implement submission filter parity #141

Merged
merged 7 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion IndicoV2.Abstractions/Submissions/Models/FilterConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using v2SubmissionFilter = IndicoV2.Submissions.Models.SubmissionFilter;
using ssSubmissionFilter = IndicoV2.StrawberryShake.SubmissionFilter;
using System.Linq;
using IndicoV2.StrawberryShake;

namespace IndicoV2.Submissions.Models
{
Expand All @@ -17,9 +18,25 @@ public static ssSubmissionFilter ConvertToSs(this IFilter filter)
{
return new ssSubmissionFilter()
{
Filetype = submissionFilter.FileType.Select(x => (StrawberryShake.FileType)x).ToList(),
InputFilename = submissionFilter.InputFilename,
Retrieved = submissionFilter.Retrieved,
Status = (StrawberryShake.SubmissionStatus?)submissionFilter.Status
Status = (StrawberryShake.SubmissionStatus?)submissionFilter.Status,
Reviews = new ReviewFilter() {
Rejected = submissionFilter.Reviews.Rejected,
CreatedBy = submissionFilter.Reviews.CreatedBy,
ReviewType = (StrawberryShake.ReviewType) submissionFilter.Reviews.ReviewType
},
ReviewInProgress = submissionFilter.ReviewInProgress,
FilesDeleted = submissionFilter.FilesDeleted,
CreatedAt = new StrawberryShake.DateRangeFilter() {
From = submissionFilter.CreatedAt.From,
To = submissionFilter.CreatedAt.To,
},
UpdatedAt = new StrawberryShake.DateRangeFilter() {
From = submissionFilter.UpdatedAt.From,
To = submissionFilter.UpdatedAt.To
}
};
}
else if (filter is AndFilter andfilter)
Expand Down
49 changes: 40 additions & 9 deletions IndicoV2.Abstractions/Submissions/Models/ISubmission.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

using System;
using IndicoV2.CommonModels.Pagination;

namespace IndicoV2.Submissions.Models
Expand All @@ -13,11 +14,6 @@ public interface ISubmission
/// </summary>
int Id { get; }

/// <summary>
/// Submission status. See <c><see cref="SubmissionStatus"/></c>.
/// </summary>
SubmissionStatus Status { get; }

/// <summary>
/// Dataset id.
/// </summary>
Expand All @@ -28,6 +24,31 @@ public interface ISubmission
/// </summary>
int WorkflowId { get; }

/// <summary>
/// Submission status. See <c><see cref="SubmissionStatus"/></c>.
/// </summary>
SubmissionStatus Status { get; }

DateTimeOffset? CreatedAt { get; }

DateTimeOffset? UpdatedAt { get; }

int? CreatedBy { get; }

int? UpdatedBy { get; }

DateTimeOffset? CompletedAt { get; }


/// <summary>
/// Submission errors.
/// </summary>
string Errors { get; }

bool? FilesDeleted { get; }

SubmissionFile[] InputFiles { get; }

/// <summary>
/// Submission input file.
/// </summary>
Expand All @@ -43,14 +64,24 @@ public interface ISubmission
/// </summary>
string ResultFile { get; }

SubmissionOutput[] OutputFiles { get; }

/// <summary>
/// Is submission retrieved.
/// </summary>
bool Retrieved { get; }

/// <summary>
/// Submission errors.
/// </summary>
string Errors { get; }
Review AutoReview { get; }

SubmissionRetry[] Retries { get; }

bool? AutoReviewLoaded { get; }

string OcrEngine { get; }

Review[] Reviews { get; }

bool? ReviewInProgress { get; }

}
}
174 changes: 162 additions & 12 deletions IndicoV2.Abstractions/Submissions/Models/Submission.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,118 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using IndicoV2.StrawberryShake;

namespace IndicoV2.Submissions.Models
{
public class SubmissionFile
nateshim-indico marked this conversation as resolved.
Show resolved Hide resolved
{
public int? Id { get; set; }

public string FilePath { get; set; }

public string FileName { get; set; }

public FileType? FileType { get; set; }

public int? SubmissionId { get; set; }

public int? FileSize { get; set; }

public int? NumPages { get; set; }
}

public class SubmissionOutput
{
public int? Id { get; set; }

public string FilePath { get; set; }

public int? SubmissionId { get; set; }

public int? ComponentId { get; set; }

public DateTimeOffset? CreatedAt { get; set; }
}

public class Review
{
public int? Id { get; set; }

public int? SubmissionId { get; set; }

public string CreatedAt { get; set; }

public int? CreatedBy { get; set; }

public string StartedAt { get; set; }

public string CompletedAt { get; set; }

public bool? Rejected { get; set; }

public ReviewType? ReviewType { get; set; }

public string Notes { get; set; }

public string Changes { get; set; }
}

public class SubmissionRetry
{
public int? Id { get; set; }

public int? SubmissionId { get; set; }

public string PreviousErrors { get; set; }

public SubmissionStatus? PreviousStatus { get; set; }

public string RetryErrors { get; set; }
}

public class Submission : ISubmission
{
/// <summary>
/// Submission id.
/// </summary>
public int Id { get; set; }

/// <summary>
/// Dataset id.
/// </summary>
public int DatasetId { get; set; }

/// <summary>
/// Workflow id.
/// </summary>
public int WorkflowId { get; set; }

/// <summary>
/// Submission status. See <c><see cref="SubmissionStatus"/></c>.
/// </summary>
public SubmissionStatus Status { get; set; }

public DateTimeOffset? CreatedAt { get; set; }

public DateTimeOffset? UpdatedAt { get; set; }

public int? CreatedBy { get; set; }

public int? UpdatedBy { get; set; }

public DateTimeOffset? CompletedAt { get; set; }

/// <summary>
/// Dataset id.
/// Submission errors.
/// </summary>
public int DatasetId { get; set; }
public string Errors { get; set; }

/// <summary>
/// Workflow id.
/// Is submission deleted.
/// </summary>
public int WorkflowId { get; set; }
public bool? FilesDeleted { get; set; }

public SubmissionFile[] InputFiles { get; set; }

/// <summary>
/// Submission input file.
Expand All @@ -42,15 +129,24 @@ public class Submission : ISubmission
/// </summary>
public string ResultFile { get; set; }

public SubmissionOutput[] OutputFiles { get; set; }

/// <summary>
/// Is submission retrieved.
/// </summary>
public bool Retrieved { get; set; }

/// <summary>
/// Submission errors.
/// </summary>
public string Errors { get; set; }
public Review AutoReview { get; set; }

public SubmissionRetry[] Retries { get; set; }

public bool? AutoReviewLoaded { get; set; }

public string OcrEngine { get; set; }

public Review[] Reviews { get; set; }

public bool? ReviewInProgress { get; set; }
}

public class SubmissionSs : Submission
Expand All @@ -60,14 +156,68 @@ public SubmissionSs(IListSubmissions_Submissions_Submissions submission)
{
_ssSubmission = submission;
Id = _ssSubmission.Id ?? 0;
Status = ConvertFromSs();
DatasetId = _ssSubmission.DatasetId ?? 0;
WorkflowId = _ssSubmission.WorkflowId ?? 0;
Status = ConvertFromSs();
CreatedAt = _ssSubmission.CreatedAt;
UpdatedAt = _ssSubmission.UpdatedAt;
CreatedBy = _ssSubmission.CreatedBy;
UpdatedBy = _ssSubmission.UpdatedBy;
CompletedAt = _ssSubmission.CompletedAt;
Errors = _ssSubmission.Errors;
FilesDeleted = _ssSubmission.FilesDeleted;
InputFiles = _ssSubmission.InputFiles.Select(inputFile => new SubmissionFile
{
Id = inputFile.Id,
FilePath = inputFile.Filepath,
FileName = inputFile.Filename,
FileType = (FileType)inputFile.Filetype,
SubmissionId = inputFile.SubmissionId,
FileSize = inputFile.FileSize,
NumPages = inputFile.NumPages
}).ToArray();
InputFile = _ssSubmission.InputFile;
InputFilename = _ssSubmission.InputFilename;
ResultFile = _ssSubmission.ResultFile;
OutputFiles = _ssSubmission.OutputFiles.Select(x => new SubmissionOutput() { }).ToArray();
Retrieved = _ssSubmission.Retrieved ?? throw new ArgumentException("Invalid value for retrieved received from call");
Errors = _ssSubmission.Errors;
AutoReview = _ssSubmission.AutoReview != null ? new Review
{
Id = _ssSubmission.AutoReview.Id,
SubmissionId = _ssSubmission.AutoReview.SubmissionId,
CreatedAt = _ssSubmission.AutoReview.CreatedAt,
CreatedBy = _ssSubmission.AutoReview.CreatedBy,
StartedAt = _ssSubmission.AutoReview.StartedAt,
CompletedAt = _ssSubmission.AutoReview.CompletedAt,
Rejected = _ssSubmission.AutoReview.Rejected,
ReviewType = (ReviewType)_ssSubmission.AutoReview.ReviewType,
Notes = _ssSubmission.AutoReview.Notes,
Changes = _ssSubmission.AutoReview.Changes
} : new Review() { };
Retries = _ssSubmission.Retries.Select(submissionRetry => new SubmissionRetry
{
Id = submissionRetry.Id,
SubmissionId = submissionRetry.SubmissionId,
PreviousErrors = submissionRetry.PreviousErrors,
PreviousStatus = (SubmissionStatus)submissionRetry.PreviousStatus,
RetryErrors = submissionRetry.RetryErrors
}).ToArray();
AutoReviewLoaded = _ssSubmission.AutoReviewLoaded;
OcrEngine = _ssSubmission.OcrEngine;
Reviews = _ssSubmission.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 = (ReviewType)review.ReviewType,
Notes = review.Notes,
Changes = review.Changes
}).ToArray();
ReviewInProgress = _ssSubmission.ReviewInProgress;
}


Expand Down
Loading
Loading