< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.ActivityExecutions.List.List
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/ActivityExecutions/List/Endpoint.cs
Line coverage
37%
Covered lines: 6
Uncovered lines: 10
Coverable lines: 16
Total lines: 46
Line coverage: 37.5%
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/ActivityExecutions/List/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Common.Entities;
 3using Elsa.Models;
 4using Elsa.Workflows.Runtime;
 5using Elsa.Workflows.Runtime.Entities;
 6using Elsa.Workflows.Runtime.Filters;
 7using Elsa.Workflows.Runtime.OrderDefinitions;
 8using JetBrains.Annotations;
 9
 10namespace Elsa.Workflows.Api.Endpoints.ActivityExecutions.List;
 11
 12/// <summary>
 13/// Lists the executions for a given activity.
 14/// </summary>
 15[PublicAPI]
 16internal class List : ElsaEndpoint<Request, ListResponse<ActivityExecutionRecord>>
 17{
 18    private readonly IActivityExecutionStore _store;
 19
 20    /// <inheritdoc />
 121    public List(IActivityExecutionStore store)
 22    {
 123        _store = store;
 124    }
 25
 26    /// <inheritdoc />
 27    public override void Configure()
 28    {
 129        Get("/activity-executions/list");
 130        ConfigurePermissions("read:activity-execution");
 131    }
 32
 33    /// <inheritdoc />
 34    public override async Task<ListResponse<ActivityExecutionRecord>> ExecuteAsync(Request request, CancellationToken ca
 35    {
 036        var filter = new ActivityExecutionRecordFilter
 037        {
 038            WorkflowInstanceId = request.WorkflowInstanceId,
 039            ActivityNodeId = request.ActivityNodeId,
 040            Completed = request.Completed
 041        };
 042        var order = new ActivityExecutionRecordOrder<DateTimeOffset>(x => x.StartedAt, OrderDirection.Ascending);
 043        var records = (await _store.FindManyAsync(filter, order, cancellationToken)).ToList();
 044        return new ListResponse<ActivityExecutionRecord>(records);
 045    }
 46}