< Summary

Information
Class: Elsa.Scheduling.Handlers.ScheduleWorkflows
Assembly: Elsa.Scheduling
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Handlers/ScheduleWorkflows.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 41
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
HandleAsync()100%11100%
HandleAsync()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Handlers/ScheduleWorkflows.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Workflows.Runtime.Notifications;
 3
 4namespace Elsa.Scheduling.Handlers;
 5
 6/// <summary>
 7/// Updates scheduled jobs based on updated workflow triggers and bookmarks.
 8/// </summary>
 9public class ScheduleWorkflows : INotificationHandler<WorkflowTriggersIndexed>, INotificationHandler<WorkflowBookmarksIn
 10{
 11    private readonly ITriggerScheduler _triggerScheduler;
 12    private readonly IBookmarkScheduler _bookmarkScheduler;
 13
 14    /// <summary>
 15    /// Initializes a new instance of the <see cref="ScheduleWorkflows"/> class.
 16    /// </summary>
 45317    public ScheduleWorkflows(ITriggerScheduler triggerScheduler, IBookmarkScheduler bookmarkScheduler)
 18    {
 45319        _triggerScheduler = triggerScheduler;
 45320        _bookmarkScheduler = bookmarkScheduler;
 45321    }
 22
 23    /// <summary>
 24    /// Updates scheduled jobs based on updated triggers.
 25    /// </summary>
 26    public async Task HandleAsync(WorkflowTriggersIndexed notification, CancellationToken cancellationToken)
 27    {
 63328        await _triggerScheduler.UnscheduleAsync(notification.IndexedWorkflowTriggers.RemovedTriggers, cancellationToken)
 63329        await _triggerScheduler.ScheduleAsync(notification.IndexedWorkflowTriggers.AddedTriggers, cancellationToken);
 63330    }
 31
 32    /// <summary>
 33    /// Updates scheduled jobs based on updated bookmarks.
 34    /// </summary>
 35    public async Task HandleAsync(WorkflowBookmarksIndexed notification, CancellationToken cancellationToken)
 36    {
 45737        var workflowInstanceId = notification.IndexedWorkflowBookmarks.WorkflowExecutionContext.Id;
 45738        await _bookmarkScheduler.UnscheduleAsync(notification.IndexedWorkflowBookmarks.RemovedBookmarks, cancellationTok
 45739        await _bookmarkScheduler.ScheduleAsync(workflowInstanceId, notification.IndexedWorkflowBookmarks.AddedBookmarks,
 45740    }
 41}