< Summary

Information
Class: Elsa.Workflows.Runtime.BookmarkUpdater
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/BookmarkUpdater.cs
Line coverage
100%
Covered lines: 21
Uncovered lines: 0
Coverable lines: 21
Total lines: 43
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
UpdateBookmarksAsync()100%11100%
RemoveBookmarksAsync()100%22100%
StoreBookmarksAsync()100%44100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/BookmarkUpdater.cs

#LineLine coverage
 1using Elsa.Workflows.Models;
 2using Elsa.Workflows.Runtime.Filters;
 3using Elsa.Workflows.Runtime.Requests;
 4
 5namespace Elsa.Workflows.Runtime;
 6
 7/// <inheritdoc />
 4378public class BookmarkUpdater(IBookmarkManager bookmarkManager, IBookmarkStore bookmarkStore) : IBookmarkUpdater
 9{
 10    /// <inheritdoc />
 11    public async Task UpdateBookmarksAsync(UpdateBookmarksRequest request, CancellationToken cancellationToken = default
 12    {
 46613        var instanceId = request.WorkflowExecutionContext.Id;
 46614        await RemoveBookmarksAsync(instanceId, request.Diff.Removed.ToList(), cancellationToken);
 46615        await StoreBookmarksAsync(request.WorkflowExecutionContext, request.Diff.Added.ToList(), cancellationToken);
 46616    }
 17
 18    private async Task RemoveBookmarksAsync(string workflowInstanceId, ICollection<Bookmark> bookmarks, CancellationToke
 19    {
 46620        if (bookmarks.Count == 0)
 42421            return;
 22
 8823        var matchingIds = bookmarks.Select(x => x.Id).ToList();
 4224        var filter = new BookmarkFilter
 4225        {
 4226            BookmarkIds = matchingIds,
 4227            WorkflowInstanceId = workflowInstanceId
 4228        };
 4229        await bookmarkManager.DeleteManyAsync(filter, cancellationToken);
 46630    }
 31
 32    private async Task StoreBookmarksAsync(WorkflowExecutionContext context, ICollection<Bookmark> bookmarks, Cancellati
 33    {
 46634        if (bookmarks.Count == 0)
 41635            return;
 36
 21437        foreach (var bookmark in bookmarks)
 38        {
 5739            var storedBookmark = context.MapBookmark(bookmark);
 5740            await bookmarkStore.SaveAsync(storedBookmark, cancellationToken);
 41        }
 46642    }
 43}