< Summary

Information
Class: Elsa.Workflows.Runtime.Filters.TriggerFilter
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Filters/TriggerFilter.cs
Line coverage
100%
Covered lines: 24
Uncovered lines: 0
Coverable lines: 24
Total lines: 81
Line coverage: 100%
Branch coverage
77%
Covered branches: 14
Total branches: 18
Branch coverage: 77.7%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_Ids()100%11100%
get_WorkflowDefinitionId()100%11100%
get_WorkflowDefinitionVersionId()100%11100%
get_WorkflowDefinitionIds()100%11100%
get_WorkflowDefinitionVersionIds()100%11100%
get_Name()100%11100%
get_Names()100%11100%
get_Hash()100%11100%
get_TenantAgnostic()100%11100%
Apply(...)77.77%1818100%
ByNames(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Filters/TriggerFilter.cs

#LineLine coverage
 1using Elsa.Workflows.Runtime.Entities;
 2
 3namespace Elsa.Workflows.Runtime.Filters;
 4
 5/// <summary>
 6/// Represents a filter for triggers.
 7/// </summary>
 8public class TriggerFilter
 9{
 10    /// <summary>
 11    /// Gets or sets the ID of the trigger to find.
 12    /// </summary>
 141213    public string? Id { get; set; }
 14
 15    /// <summary>
 16    /// Gets or sets the IDs of the triggers to find.
 17    /// </summary>
 142018    public ICollection<string>? Ids { get; set; }
 19
 20    /// <summary>
 21    /// Gets or sets the ID of the workflow definition.
 22    /// </summary>
 256623    public string? WorkflowDefinitionId { get; set; }
 24
 25    /// <summary>
 26    /// Gets or sets the ID of the workflow definition version.
 27    /// </summary>
 141228    public string? WorkflowDefinitionVersionId { get; set; }
 29
 30    /// <summary>
 31    /// Gets or sets the IDs of the workflow definitions.
 32    /// </summary>
 141233    public ICollection<string>? WorkflowDefinitionIds { get; set; }
 34
 35    /// <summary>
 36    /// Gets or sets the IDs of the workflow definition versions.
 37    /// </summary>
 141238    public ICollection<string>? WorkflowDefinitionVersionIds { get; set; }
 39
 40    /// <summary>
 41    /// Gets or sets the name of the trigger to find.
 42    /// </summary>
 142843    public string? Name { get; set; }
 44
 45    /// <summary>
 46    /// Gets or sets the names of the triggers to find.
 47    /// </summary>
 141648    public ICollection<string>? Names { get; set; }
 49
 50    /// <summary>
 51    /// Gets or sets the hash of the trigger to find.
 52    /// </summary>
 165553    public string? Hash { get; set; }
 54
 55    /// <summary>
 56    /// Get or sets if the triggers to find is a tenant agnostic search
 57    /// </summary>
 124358    public bool TenantAgnostic { get; set; }
 59
 60    /// <summary>
 61    /// Applies the filter to the specified query.
 62    /// </summary>
 63    public IQueryable<StoredTrigger> Apply(IQueryable<StoredTrigger> queryable)
 64    {
 69565        if (Id != null) queryable = queryable.Where(x => x.Id == Id);
 69966        if (Ids != null) queryable = queryable.Where(x => Ids.Contains(x.Id));
 134167        if (WorkflowDefinitionId != null) queryable = queryable.Where(x => x.WorkflowDefinitionId == WorkflowDefinitionI
 69568        if (WorkflowDefinitionIds != null) queryable = queryable.Where(x => WorkflowDefinitionIds.Contains(x.WorkflowDef
 69569        if (WorkflowDefinitionVersionId != null) queryable = queryable.Where(x => x.WorkflowDefinitionVersionId == Workf
 69570        if (WorkflowDefinitionVersionIds != null) queryable = queryable.Where(x => WorkflowDefinitionVersionIds.Contains
 70471        if (Name != null) queryable = queryable.Where(x => x.Name == Name);
 69772        if (Names != null) queryable = queryable.Where(x => Names.Contains(x.Name!));
 72373        if (Hash != null) queryable = queryable.Where(x => x.Hash == Hash);
 69574        return queryable;
 75    }
 76
 177    public static TriggerFilter ByNames(IEnumerable<string> names) => new()
 178    {
 179        Names = names.ToList()
 180    };
 81}