< 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: 70
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.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.FilteredList;
 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        Post("/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);
 37
 038        var filter = new WorkflowExecutionLogRecordFilter
 039        {
 040            WorkflowInstanceId = request.WorkflowInstanceId,
 041            ActivityIds = request.Filter?.ActivityIds,
 042            ActivityNodeIds = request.Filter?.ActivityNodeIds,
 043            ExcludeActivityTypes = request.Filter?.ExcludedActivityTypes,
 044            EventNames = request.Filter?.EventNames,
 045        };
 046        var order = new WorkflowExecutionLogRecordOrder<long>(x => x.Sequence, OrderDirection.Ascending);
 047        var pageOfRecords = await _store.FindManyAsync(filter, pageArgs, order, cancellationToken);
 48
 049        var models = pageOfRecords.Items.Select(x =>
 050                new ExecutionLogRecord(
 051                    x.Id,
 052                    x.ActivityInstanceId,
 053                    x.ParentActivityInstanceId,
 054                    x.ActivityId,
 055                    x.ActivityType,
 056                    x.ActivityTypeVersion,
 057                    x.ActivityName,
 058                    x.ActivityNodeId,
 059                    x.Timestamp,
 060                    x.Sequence,
 061                    x.EventName,
 062                    x.Message,
 063                    x.Source,
 064                    x.ActivityState,
 065                    x.Payload))
 066            .ToList();
 67
 068        return new(models, pageOfRecords.TotalCount);
 069    }
 70}