< Summary

Information
Class: Elsa.Alterations.Core.Filters.AlterationJobFilter
Assembly: Elsa.Alterations.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations.Core/Filters/AlterationJobFilter.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 50
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
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_Id()100%210%
get_PlanId()100%210%
get_Status()100%210%
get_Statuses()100%210%
Apply(...)0%7280%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations.Core/Filters/AlterationJobFilter.cs

#LineLine coverage
 1using Elsa.Alterations.Core.Entities;
 2using Elsa.Alterations.Core.Enums;
 3
 4namespace Elsa.Alterations.Core.Filters;
 5
 6/// <summary>
 7/// A filter for querying alteration jobs.
 8/// </summary>
 9public class AlterationJobFilter
 10{
 11    /// <summary>
 12    /// The ID of the job.
 13    /// </summary>
 014    public string? Id { get; set; }
 15
 16    /// <summary>
 17    /// The ID of the plan.
 18    /// </summary>
 019    public string? PlanId { get; set; }
 20
 21    /// <summary>
 22    /// The status of the job.
 23    /// </summary>
 024    public AlterationJobStatus? Status { get; set; }
 25
 26    /// <summary>
 27    /// The statuses of the job to match.
 28    /// </summary>
 029    public ICollection<AlterationJobStatus>? Statuses { get; set; }
 30
 31    /// <summary>
 32    /// Applies the filter to the specified query.
 33    /// </summary>
 34    public IQueryable<AlterationJob> Apply(IQueryable<AlterationJob> query)
 35    {
 036        if (!string.IsNullOrWhiteSpace(Id))
 037            query = query.Where(x => x.Id == Id);
 38
 039        if (!string.IsNullOrWhiteSpace(PlanId))
 040            query = query.Where(x => x.PlanId == PlanId);
 41
 042        if (Status != null)
 043            query = query.Where(x => x.Status == Status);
 44
 045        if (Statuses != null)
 046            query = query.Where(x => Statuses.Contains(x.Status));
 47
 048        return query;
 49    }
 50}