< Summary

Information
Class: Elsa.Scheduling.Handlers.DeleteSchedules
Assembly: Elsa.Scheduling
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Handlers/DeleteSchedules.cs
Line coverage
75%
Covered lines: 9
Uncovered lines: 3
Coverable lines: 12
Total lines: 40
Line coverage: 75%
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

File(s)

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

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Workflows.Management.Notifications;
 3using Elsa.Workflows.Runtime;
 4using Elsa.Workflows.Runtime.Filters;
 5using Elsa.Workflows.Runtime.Notifications;
 6
 7namespace Elsa.Scheduling.Handlers;
 8
 9/// <summary>
 10/// Deletes scheduled jobs based on deleted workflow triggers and bookmarks.
 11/// </summary>
 45312public class DeleteSchedules(ITriggerScheduler triggerScheduler, IBookmarkScheduler bookmarkScheduler, ITriggerStore tri
 13    :
 14        INotificationHandler<WorkflowDefinitionDeleting>,
 15        INotificationHandler<WorkflowDefinitionsDeleting>,
 16        INotificationHandler<WorkflowDefinitionVersionDeleting>,
 17        INotificationHandler<WorkflowDefinitionVersionsDeleting>,
 18        INotificationHandler<BookmarksDeleting>
 19{
 20    async Task INotificationHandler<BookmarksDeleting>.HandleAsync(BookmarksDeleting notification, CancellationToken can
 21    {
 9922        var ids = notification.Bookmarks.Select(x => x.Id).ToList();
 5223        var bookmarks = await bookmarkStore.FindManyAsync(new BookmarkFilter { BookmarkIds = ids }, cancellationToken);
 5224        await bookmarkScheduler.UnscheduleAsync(bookmarks, cancellationToken);
 5225    }
 26
 427    async Task INotificationHandler<WorkflowDefinitionDeleting>.HandleAsync(WorkflowDefinitionDeleting notification, Can
 028    async Task INotificationHandler<WorkflowDefinitionsDeleting>.HandleAsync(WorkflowDefinitionsDeleting notification, C
 29
 30    async Task INotificationHandler<WorkflowDefinitionVersionDeleting>.HandleAsync(WorkflowDefinitionVersionDeleting not
 031        await RemoveSchedulesAsync(new TriggerFilter { WorkflowDefinitionVersionId = notification.WorkflowDefinition.Id 
 32
 033    async Task INotificationHandler<WorkflowDefinitionVersionsDeleting>.HandleAsync(WorkflowDefinitionVersionsDeleting n
 34
 35    private async Task RemoveSchedulesAsync(TriggerFilter filter, CancellationToken cancellationToken)
 36    {
 437        var triggers = await triggerStore.FindManyAsync(filter, cancellationToken);
 438        await triggerScheduler.UnscheduleAsync(triggers, cancellationToken);
 439    }
 40}