< Summary

Information
Class: GistBackend.Utils.ServiceUtils
Assembly: GistBackend
File(s): /home/runner/work/the-gist-of-it-sec/the-gist-of-it-sec/backend/GistBackend/Utils/ServiceUtils.cs
Line coverage
57%
Covered lines: 4
Uncovered lines: 3
Coverable lines: 7
Total lines: 24
Line coverage: 57.1%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
DelayUntilNextExecutionAsync()50%9657.14%

File(s)

/home/runner/work/the-gist-of-it-sec/the-gist-of-it-sec/backend/GistBackend/Utils/ServiceUtils.cs

#LineLine coverage
 1using GistBackend.Handlers;
 2using Microsoft.Extensions.Logging;
 3using static GistBackend.Utils.LogEvents;
 4
 5namespace GistBackend.Utils;
 6
 7public static class ServiceUtils
 8{
 9    public static async Task DelayUntilNextExecutionAsync(DateTime startTime, double delayMinutes, ILogger? logger,
 10        CancellationToken ct, IDateTimeHandler? dateTimeHandler = null)
 11    {
 3112        var now = dateTimeHandler?.GetUtcNow() ?? DateTime.UtcNow;
 3113        var delay = startTime.AddMinutes(delayMinutes) - now;
 3114        if (delay > TimeSpan.Zero)
 15        {
 3116            await Task.Delay(delay, ct);
 17        }
 18        else
 19        {
 020            logger?.LogWarning(GistServiceDelayExceeded,
 021                "Processing entries took longer than delay timeframe");
 22        }
 023    }
 24}

Methods/Properties

DelayUntilNextExecutionAsync()