< Summary

Information
Class: Elsa.Workflows.Runtime.StoreActivityExecutionLogSink
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/StoreActivityExecutionLogSink.cs
Line coverage
91%
Covered lines: 11
Uncovered lines: 1
Coverable lines: 12
Total lines: 34
Line coverage: 91.6%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
PersistExecutionLogsAsync()75%4485.71%

File(s)

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

#LineLine coverage
 1using Elsa.Extensions;
 2using Elsa.Mediator.Contracts;
 3using Elsa.Workflows.Runtime.Entities;
 4using Elsa.Workflows.Runtime.Notifications;
 5
 6namespace Elsa.Workflows.Runtime;
 7
 8/// <summary>
 9/// This implementation saves <see cref="ActivityExecutionRecord"/> directly through the store.
 10/// </summary>
 43711public class StoreActivityExecutionLogSink(
 43712    IActivityExecutionStore activityExecutionStore,
 43713    INotificationSender notificationSender)
 14    : ILogRecordSink<ActivityExecutionRecord>
 15{
 16    /// <inheritdoc />
 17    public async Task PersistExecutionLogsAsync(WorkflowExecutionContext context, CancellationToken cancellationToken = 
 18    {
 19        // Select tainted activity execution contexts to avoid saving untainted ones multiple times.
 425720        var activityExecutionContexts = context.ActivityExecutionContexts.Where(x => x.IsDirty).ToList();
 21
 46622        if (activityExecutionContexts.Count == 0)
 023            return;
 24
 425725        var records = await Task.WhenAll(activityExecutionContexts.Select(x => x.GetOrMapCapturedActivityExecutionRecord
 46626        await activityExecutionStore.SaveManyAsync(records, cancellationToken);
 27
 28        // Untaint activity execution contexts.
 851429        foreach (var activityExecutionContext in activityExecutionContexts)
 379130            activityExecutionContext.ClearTaint();
 31
 46632        await notificationSender.SendAsync(new ActivityExecutionLogUpdated(context, records), cancellationToken);
 46633    }
 34}