< Summary

Information
Class: Elsa.Workflows.Runtime.Filters.WorkflowInboxMessageFilter
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Filters/WorkflowInboxMessageFilter.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 56
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 12
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ActivityTypeName()100%210%
get_Hash()100%210%
get_WorkflowInstanceId()100%210%
get_CorrelationId()100%210%
get_ActivityInstanceId()100%210%
get_IsExpired()100%210%
Apply(...)0%156120%

File(s)

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

#LineLine coverage
 1using Elsa.Workflows.Runtime.Entities;
 2
 3namespace Elsa.Workflows.Runtime.Filters;
 4
 5/// <summary>
 6/// A filter that can be used to find messages in the workflow inbox.
 7/// </summary>
 8public class WorkflowInboxMessageFilter
 9{
 10    /// <summary>
 11    /// The activity type name to filter by.
 12    /// </summary>
 013    public string? ActivityTypeName { get; set; }
 14
 15    /// <summary>
 16    /// The hash of the bookmark payload to filter by.
 17    /// </summary>
 018    public string? Hash { get; set; }
 19
 20    /// <summary>
 21    /// The ID of the workflow instance to filter by.
 22    /// </summary>
 023    public string? WorkflowInstanceId { get; set; }
 24
 25    /// <summary>
 26    /// The correlation ID of the workflow instance to filter by.
 27    /// </summary>
 028    public string? CorrelationId { get; set; }
 29
 30    /// <summary>
 31    /// The ID of the activity instance to filter by.
 32    /// </summary>
 033    public string? ActivityInstanceId { get; set; }
 34
 35    /// <summary>
 36    /// A flag indicating whether to filter by messages that have expired.
 37    /// </summary>
 038    public bool? IsExpired { get; set; }
 39
 40    /// <summary>
 41    /// Applies the filter to the specified query.
 42    /// </summary>
 43    /// <returns>The filtered query.</returns>
 44    public IQueryable<WorkflowInboxMessage> Apply(IQueryable<WorkflowInboxMessage> query, DateTimeOffset now)
 45    {
 046        var filter = this;
 047        if (filter.CorrelationId != null) query = query.Where(x => filter.CorrelationId == x.CorrelationId);
 048        if (filter.WorkflowInstanceId != null) query = query.Where(x => filter.WorkflowInstanceId == x.WorkflowInstanceI
 049        if (filter.Hash != null) query = query.Where(x => filter.Hash == x.Hash);
 050        if (filter.ActivityTypeName != null) query = query.Where(x => filter.ActivityTypeName == x.ActivityTypeName);
 051        if (filter.ActivityInstanceId != null) query = query.Where(x => filter.ActivityInstanceId == x.ActivityInstanceI
 052        if (filter.IsExpired != null) query = query.Where(x => x.ExpiresAt <= now);
 53
 054        return query;
 55    }
 56}