< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowInstances.Journal.List.Get
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Journal/List/Endpoint.cs
Line coverage
20%
Covered lines: 6
Uncovered lines: 24
Coverable lines: 30
Total lines: 62
Line coverage: 20%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Configure()100%11100%
ExecuteAsync()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Journal/List/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Common.Entities;
 3using Elsa.Common.Models;
 4using Elsa.Workflows.Api.Models;
 5using Elsa.Workflows.Runtime;
 6using Elsa.Workflows.Runtime.Filters;
 7using Elsa.Workflows.Runtime.OrderDefinitions;
 8using JetBrains.Annotations;
 9
 10namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.Journal.List;
 11
 12/// <summary>
 13/// Gets the journal for a workflow instance.
 14/// </summary>
 15[PublicAPI]
 16internal class Get : ElsaEndpoint<Request, Response>
 17{
 18    private readonly IWorkflowExecutionLogStore _store;
 19
 20    /// <inheritdoc />
 121    public Get(IWorkflowExecutionLogStore store)
 22    {
 123        _store = store;
 124    }
 25
 26    /// <inheritdoc />
 27    public override void Configure()
 28    {
 129        Get("/workflow-instances/{id}/journal");
 130        ConfigurePermissions("read:workflow-instances");
 131    }
 32
 33    /// <inheritdoc />
 34    public override async Task<Response> ExecuteAsync(Request request, CancellationToken cancellationToken)
 35    {
 036        var pageArgs = PageArgs.From(request.Page, request.PageSize, request.Skip, request.Take);
 037        var filter = new WorkflowExecutionLogRecordFilter { WorkflowInstanceId = request.WorkflowInstanceId };
 038        var order = new WorkflowExecutionLogRecordOrder<long>(x => x.Sequence, OrderDirection.Ascending);
 039        var pageOfRecords = await _store.FindManyAsync(filter, pageArgs, order, cancellationToken);
 40
 041        var models = pageOfRecords.Items.Select(x =>
 042                new ExecutionLogRecord(
 043                    x.Id,
 044                    x.ActivityInstanceId,
 045                    x.ParentActivityInstanceId,
 046                    x.ActivityId,
 047                    x.ActivityType,
 048                    x.ActivityTypeVersion,
 049                    x.ActivityName,
 050                    x.ActivityNodeId,
 051                    x.Timestamp,
 052                    x.Sequence,
 053                    x.EventName,
 054                    x.Message,
 055                    x.Source,
 056                    x.ActivityState,
 057                    x.Payload))
 058            .ToList();
 59
 060        return new(models, pageOfRecords.TotalCount);
 061    }
 62}