< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowInstances.Journal.FilteredList.Get
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Journal/FilteredList/Endpoint.cs
Line coverage
16%
Covered lines: 6
Uncovered lines: 31
Coverable lines: 37
Total lines: 71
Line coverage: 16.2%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
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()0%7280%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Journal/FilteredList/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.FilteredList;
 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        Post("/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);
 38
 039        var filter = new WorkflowExecutionLogRecordFilter
 040        {
 041            WorkflowInstanceId = request.WorkflowInstanceId,
 042            ActivityIds = request.Filter?.ActivityIds,
 043            ActivityNodeIds = request.Filter?.ActivityNodeIds,
 044            ExcludeActivityTypes = request.Filter?.ExcludedActivityTypes,
 045            EventNames = request.Filter?.EventNames,
 046        };
 047        var order = new WorkflowExecutionLogRecordOrder<long>(x => x.Sequence, OrderDirection.Ascending);
 048        var pageOfRecords = await _store.FindManyAsync(filter, pageArgs, order, cancellationToken);
 49
 050        var models = pageOfRecords.Items.Select(x =>
 051                new ExecutionLogRecord(
 052                    x.Id,
 053                    x.ActivityInstanceId,
 054                    x.ParentActivityInstanceId,
 055                    x.ActivityId,
 056                    x.ActivityType,
 057                    x.ActivityTypeVersion,
 058                    x.ActivityName,
 059                    x.ActivityNodeId,
 060                    x.Timestamp,
 061                    x.Sequence,
 062                    x.EventName,
 063                    x.Message,
 064                    x.Source,
 065                    x.ActivityState,
 066                    x.Payload))
 067            .ToList();
 68
 069        return new(models, pageOfRecords.TotalCount);
 070    }
 71}