< Summary

Information
Class: Elsa.Workflows.Runtime.Filters.ActivityExecutionRecordFilter
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Filters/ActivityExecutionRecordFilter.cs
Line coverage
68%
Covered lines: 28
Uncovered lines: 13
Coverable lines: 41
Total lines: 115
Line coverage: 68.2%
Branch coverage
35%
Covered branches: 21
Total branches: 60
Branch coverage: 35%
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_WorkflowInstanceId()100%11100%
get_WorkflowInstanceIds()100%11100%
get_ActivityId()100%11100%
get_ActivityIds()100%11100%
get_ActivityNodeId()100%11100%
get_ActivityNodeIds()100%11100%
get_Name()100%11100%
get_Names()100%11100%
get_Status()100%11100%
get_Statuses()100%11100%
get_Completed()100%11100%
get_IsEmpty()0%600240%
Apply(...)55.55%3636100%

File(s)

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

#LineLine coverage
 1using Elsa.Workflows.Runtime.Entities;
 2
 3namespace Elsa.Workflows.Runtime.Filters;
 4
 5/// <summary>
 6/// A specification to use when finding activity execution log records. Only non-null fields will be included in the con
 7/// </summary>
 8public class ActivityExecutionRecordFilter
 9{
 10    /// <summary>
 11    /// The ID of the activity execution record.
 12    /// </summary>
 3013    public string? Id { get; set; }
 14
 15    /// <summary>
 16    /// The IDs of the activity execution records.
 17    /// </summary>
 3018    public ICollection<string>? Ids { get; set; }
 19
 20    /// <summary>
 21    /// The ID of the workflow instance.
 22    /// </summary>
 5023    public string? WorkflowInstanceId { get; set; }
 24
 25    /// <summary>
 26    /// The IDs of the workflow instances.
 27    /// </summary>
 5628    public ICollection<string>? WorkflowInstanceIds { get; set; }
 29
 30    /// <summary>
 31    /// The ID of the activity.
 32    /// </summary>
 5133    public string? ActivityId { get; set; }
 34
 35    /// <summary>
 36    /// The IDs of the activities.
 37    /// </summary>
 3038    public ICollection<string>? ActivityIds { get; set; }
 39
 40    /// <summary>
 41    /// The node ID of the activity.
 42    /// </summary>
 3043    public string? ActivityNodeId { get; set; }
 44
 45    /// <summary>
 46    /// The node IDs of the activities.
 47    /// </summary>
 3048    public ICollection<string>? ActivityNodeIds { get; set; }
 49
 50    /// <summary>
 51    /// The name of the activity.
 52    /// </summary>
 3253    public string? Name { get; set; }
 54
 55    /// <summary>
 56    /// The names of the activities.
 57    /// </summary>
 3058    public ICollection<string>? Names { get; set; }
 59
 60    /// <summary>
 61    /// The status of the activity.
 62    /// </summary>
 3063    public ActivityStatus? Status { get; set; }
 64
 65    /// <summary>
 66    /// The statuses of the activities.
 67    /// </summary>
 3068    public ICollection<ActivityStatus>? Statuses { get; set; }
 69
 70    /// <summary>
 71    /// Whether to include completed activity execution records. If not specified, all activity execution records will b
 72    /// </summary>
 3073    public bool? Completed { get; set; }
 74
 75    /// <summary>
 76    /// Returns true if the filter is empty.
 77    /// </summary>
 78    public bool IsEmpty =>
 079        Id == null
 080        && Ids == null
 081        && WorkflowInstanceId == null
 082        && WorkflowInstanceIds == null
 083        && ActivityId == null
 084        && ActivityIds == null
 085        && ActivityNodeId == null
 086        && ActivityNodeIds == null
 087        && Name == null
 088        && Names == null
 089        && Status == null
 090        && Statuses == null
 091        && Completed == null;
 92
 93    /// <summary>
 94    /// Applies the filter to the specified queryable.
 95    /// </summary>
 96    public IQueryable<ActivityExecutionRecord> Apply(IQueryable<ActivityExecutionRecord> queryable)
 97    {
 3098        var filter = this;
 3099        if (filter.Id != null) queryable = queryable.Where(x => x.Id == filter.Id);
 30100        if (filter.Ids != null) queryable = queryable.Where(x => filter.Ids.Contains(x.Id));
 40101        if (filter.WorkflowInstanceId != null) queryable = queryable.Where(x => x.WorkflowInstanceId == filter.WorkflowI
 43102        if (filter.WorkflowInstanceIds != null) queryable = queryable.Where(x => filter.WorkflowInstanceIds.Contains(x.W
 36103        if (filter.ActivityId != null) queryable = queryable.Where(x => x.ActivityId == filter.ActivityId);
 30104        if (filter.ActivityIds != null && filter.ActivityIds.Any()) queryable = queryable.Where(x => filter.ActivityIds.
 30105        if (filter.ActivityNodeId != null) queryable = queryable.Where(x => x.ActivityNodeId == filter.ActivityNodeId);
 30106        if (filter.ActivityNodeIds != null && filter.ActivityNodeIds.Any()) queryable = queryable.Where(x => filter.Acti
 31107        if (filter.Name != null) queryable = queryable.Where(x => x.ActivityName == filter.Name);
 30108        if (filter.Names != null && filter.Names.Any()) queryable = queryable.Where(x => filter.Names.Contains(x.Activit
 30109        if (filter.Status != null) queryable = queryable.Where(x => x.Status == filter.Status);
 30110        if (filter.Statuses != null && filter.Statuses.Any()) queryable = queryable.Where(x => filter.Statuses.Contains(
 30111        if (filter.Completed != null) queryable = filter.Completed == true ? queryable.Where(x => x.CompletedAt != null)
 112
 30113        return queryable;
 114    }
 115}