< 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: 63
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.Authorization;
 2using Elsa.Abstractions;
 3using Elsa.Common.Entities;
 4using Elsa.Common.Models;
 5using Elsa.Workflows.Api.Models;
 6using Elsa.Workflows.Runtime;
 7using Elsa.Workflows.Runtime.Filters;
 8using Elsa.Workflows.Runtime.OrderDefinitions;
 9using JetBrains.Annotations;
 10
 11namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.Journal.List;
 12
 13/// <summary>
 14/// Gets the journal for a workflow instance.
 15/// </summary>
 16[PublicAPI]
 17internal class Get : ElsaEndpoint<Request, Response>
 18{
 19    private readonly IWorkflowExecutionLogStore _store;
 20
 21    /// <inheritdoc />
 322    public Get(IWorkflowExecutionLogStore store)
 23    {
 324        _store = store;
 325    }
 26
 27    /// <inheritdoc />
 28    public override void Configure()
 29    {
 330        Get("/workflow-instances/{id}/journal");
 331        RequirePermission(Elsa.Workflows.Api.Permissions.WorkflowPermissions.Instances, CoreVerbs.View);
 332    }
 33
 34    /// <inheritdoc />
 35    public override async Task<Response> ExecuteAsync(Request request, CancellationToken cancellationToken)
 36    {
 037        var pageArgs = PageArgs.From(request.Page, request.PageSize, request.Skip, request.Take);
 038        var filter = new WorkflowExecutionLogRecordFilter { WorkflowInstanceId = request.WorkflowInstanceId };
 039        var order = new WorkflowExecutionLogRecordOrder<long>(x => x.Sequence, OrderDirection.Ascending);
 040        var pageOfRecords = await _store.FindManyAsync(filter, pageArgs, order, cancellationToken);
 41
 042        var models = pageOfRecords.Items.Select(x =>
 043                new ExecutionLogRecord(
 044                    x.Id,
 045                    x.ActivityInstanceId,
 046                    x.ParentActivityInstanceId,
 047                    x.ActivityId,
 048                    x.ActivityType,
 049                    x.ActivityTypeVersion,
 050                    x.ActivityName,
 051                    x.ActivityNodeId,
 052                    x.Timestamp,
 053                    x.Sequence,
 054                    x.EventName,
 055                    x.Message,
 056                    x.Source,
 057                    x.ActivityState,
 058                    x.Payload))
 059            .ToList();
 60
 061        return new(models, pageOfRecords.TotalCount);
 062    }
 63}