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

feature: Add created date time to filter #4932

Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public override async Task<Response> ExecuteAsync(Request request, CancellationT
WorkflowStatus = request.Status,
WorkflowSubStatus = request.SubStatus,
WorkflowStatuses = request.Statuses?.Select(Enum.Parse<WorkflowStatus>).ToList(),
WorkflowSubStatuses = request.SubStatuses?.Select(Enum.Parse<WorkflowSubStatus>).ToList()
WorkflowSubStatuses = request.SubStatuses?.Select(Enum.Parse<WorkflowSubStatus>).ToList(),
ToCreatedAt = request.ToCreatedAt,
FromCreatedAt = request.FromCreatedAt,
};

var summaries = await FindAsync(request, filter, pageArgs, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class Request
public ICollection<string>? SubStatuses { get; set; }
public OrderByWorkflowInstance? OrderBy { get; set; }
public OrderDirection? OrderDirection { get; set; }
public DateTimeOffset? FromCreatedAt { get; set; }
public DateTimeOffset? ToCreatedAt { get; set; }
}

public class Response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ public class WorkflowInstanceFilter
/// </summary>
public ICollection<WorkflowSubStatus>? WorkflowSubStatuses { get; set; }

/// <summary>
/// Filter workflow instances by created date time, start from this date time.
/// </summary>
public DateTimeOffset? FromCreatedAt { get; set; }

/// <summary>
/// Filter workflow instances by created date time, to this date time.
/// </summary>
public DateTimeOffset? ToCreatedAt { get; set; }

/// <summary>
/// Applies the filter to the specified query.
/// </summary>
Expand All @@ -96,6 +106,8 @@ public IQueryable<WorkflowInstance> Apply(IQueryable<WorkflowInstance> query)
if (filter.WorkflowSubStatus != null) query = query.Where(x => x.SubStatus == filter.WorkflowSubStatus);
if (filter.WorkflowStatuses != null) query = query.Where(x => filter.WorkflowStatuses.Contains(x.Status));
if (filter.WorkflowSubStatuses != null) query = query.Where(x => filter.WorkflowSubStatuses.Contains(x.SubStatus));
if (filter.ToCreatedAt is not null) query = query.Where(x => filter.ToCreatedAt >= x.CreatedAt);
if (filter.FromCreatedAt is not null) query = query.Where(x => filter.FromCreatedAt <= x.CreatedAt);

var searchTerm = filter.SearchTerm;
if (!string.IsNullOrWhiteSpace(searchTerm))
Expand Down