Refactor to use primary constructor in Get class

Refactored the `Get` class to utilize a primary constructor for dependency injection of `IWorkflowExecutionLogStore`. This change simplifies the class definition and removes the need for a private field.
This commit is contained in:
Sipke Schoorstra 2024-09-26 14:09:28 +02:00
parent a62de77900
commit 0492a7be43

View file

@ -12,16 +12,8 @@ namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.Journal.GetLastEntry;
/// Return the last log entry for the specified workflow instance and activity ID.
/// </summary>
[PublicAPI]
public class Get : ElsaEndpoint<Request, WorkflowExecutionLogRecord>
public class Get(IWorkflowExecutionLogStore store) : ElsaEndpoint<Request, WorkflowExecutionLogRecord>
{
private readonly IWorkflowExecutionLogStore _store;
/// <inheritdoc />
public Get(IWorkflowExecutionLogStore store)
{
_store = store;
}
/// <inheritdoc />
public override void Configure()
{
@ -36,7 +28,7 @@ public class Get : ElsaEndpoint<Request, WorkflowExecutionLogRecord>
{
WorkflowInstanceId = request.WorkflowInstanceId,
ActivityId = request.ActivityId,
EventNames = new[] { "Started", "Completed", "Faulted" }
EventNames = ["Started", "Completed", "Faulted"]
};
var sort = new WorkflowExecutionLogRecordOrder<DateTimeOffset>(
@ -44,7 +36,7 @@ public class Get : ElsaEndpoint<Request, WorkflowExecutionLogRecord>
OrderDirection.Descending
);
var entry = await _store.FindAsync(filter, sort, cancellationToken);
var entry = await store.FindAsync(filter, sort, cancellationToken);
if (entry == null)
{