From 0492a7be4356a481ec052c4e5c191aae69641685 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Thu, 26 Sep 2024 14:09:28 +0200 Subject: [PATCH] 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. --- .../Journal/GetLastEntry/Endpoint.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Journal/GetLastEntry/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Journal/GetLastEntry/Endpoint.cs index 2a3988c5d..a3f0a637f 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Journal/GetLastEntry/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Journal/GetLastEntry/Endpoint.cs @@ -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. /// [PublicAPI] -public class Get : ElsaEndpoint +public class Get(IWorkflowExecutionLogStore store) : ElsaEndpoint { - private readonly IWorkflowExecutionLogStore _store; - - /// - public Get(IWorkflowExecutionLogStore store) - { - _store = store; - } - /// public override void Configure() { @@ -36,7 +28,7 @@ public class Get : ElsaEndpoint { WorkflowInstanceId = request.WorkflowInstanceId, ActivityId = request.ActivityId, - EventNames = new[] { "Started", "Completed", "Faulted" } + EventNames = ["Started", "Completed", "Faulted"] }; var sort = new WorkflowExecutionLogRecordOrder( @@ -44,7 +36,7 @@ public class Get : ElsaEndpoint OrderDirection.Descending ); - var entry = await _store.FindAsync(filter, sort, cancellationToken); + var entry = await store.FindAsync(filter, sort, cancellationToken); if (entry == null) {