< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Version.ListVersions
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Version/List.cs
Line coverage
23%
Covered lines: 4
Uncovered lines: 13
Coverable lines: 17
Total lines: 41
Line coverage: 23.5%
Branch coverage
0%
Covered branches: 0
Total branches: 2
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%
HandleAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Version/List.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Common.Entities;
 3using Elsa.Common.Models;
 4using Elsa.Workflows.Management;
 5using Elsa.Workflows.Management.Filters;
 6using JetBrains.Annotations;
 7using Microsoft.AspNetCore.Http;
 8
 9namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Version;
 10
 11[PublicAPI]
 112internal class ListVersions(IWorkflowDefinitionStore store) : ElsaEndpointWithoutRequest
 13{
 14    public override void Configure()
 15    {
 116        Get("workflow-definitions/{definitionId}/versions");
 117        ConfigurePermissions("read:workflow-definitions");
 118    }
 19
 20    public override async Task HandleAsync(CancellationToken cancellationToken)
 21    {
 022        var definitionId = Route<string>("definitionId")!;
 23
 024        var filter = new WorkflowDefinitionFilter
 025        {
 026            DefinitionId = definitionId,
 027            VersionOptions = VersionOptions.All
 028        };
 29
 030        var orderBy = new WorkflowDefinitionOrder<int>(x => x.Version, OrderDirection.Descending);
 031        var definitions = await store.FindManyAsync(filter, orderBy, cancellationToken);
 32
 033        if (!definitions.Any())
 34        {
 035            await Send.NotFoundAsync(cancellationToken);
 036            return;
 37        }
 38
 039        await Send.OkAsync(definitions, cancellationToken);
 040    }
 41}