< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.ActivityExecutions.Count.Count
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/ActivityExecutions/Count/Endpoint.cs
Line coverage
40%
Covered lines: 6
Uncovered lines: 9
Coverable lines: 15
Total lines: 42
Line coverage: 40%
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/Count/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Models;
 3using Elsa.Workflows.Runtime;
 4using Elsa.Workflows.Runtime.Filters;
 5using JetBrains.Annotations;
 6
 7namespace Elsa.Workflows.Api.Endpoints.ActivityExecutions.Count;
 8
 9/// <summary>
 10/// Counts the number of executions for a given activity.
 11/// </summary>
 12[PublicAPI]
 13internal class Count : ElsaEndpoint<Request, CountResponse>
 14{
 15    private readonly IActivityExecutionStore _store;
 16
 17    /// <inheritdoc />
 118    public Count(IActivityExecutionStore store)
 19    {
 120        _store = store;
 121    }
 22
 23    /// <inheritdoc />
 24    public override void Configure()
 25    {
 126        Get("/activity-executions/count");
 127        ConfigurePermissions("read:activity-execution");
 128    }
 29
 30    /// <inheritdoc />
 31    public override async Task<CountResponse> ExecuteAsync(Request request, CancellationToken cancellationToken)
 32    {
 033        var filter = new ActivityExecutionRecordFilter
 034        {
 035            WorkflowInstanceId = request.WorkflowInstanceId,
 036            ActivityId = request.ActivityId,
 037            Completed = request.Completed
 038        };
 039        var count = await _store.CountAsync(filter, cancellationToken);
 040        return new CountResponse(count);
 041    }
 42}