< Summary

Information
Class: Anichron.Core.Work.ProxyDeletionPlan
Assembly: Anichron.Core
File(s): /home/runner/work/anichron/anichron/src/Anichron.Core/Work/ProxyDeletionPlan.cs
Tag: 19_45211875487
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 27
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
ForAll(...)100%11100%
ForSelection(...)100%11100%
InQueueOrder(...)100%11100%

File(s)

/home/runner/work/anichron/anichron/src/Anichron.Core/Work/ProxyDeletionPlan.cs

#LineLine coverage
 1using Anichron.Core.Data.Repository;
 2
 3namespace Anichron.Core.Work;
 4
 5/// <summary>
 6/// The deletions a request queues, in queue order: one per live storage config, by id, then one unscoped
 7/// deletion for orphans of a config that no longer exists or of none.
 8/// </summary>
 9public static class ProxyDeletionPlan
 10{
 11    /// <summary>Deletions of every unprocessed orphan of the sweep, with no selection.</summary>
 12    /// <param name="sweepId">The sweep.</param>
 13    /// <param name="pendingConfigs">Each live config, null for none, that the sweep's unprocessed orphans name.</param>
 14    public static IReadOnlyList<ProxyDeletionPayload> ForAll(Guid sweepId, IEnumerable<Guid?> pendingConfigs)
 415        => [.. InQueueOrder(pendingConfigs.Distinct(), config => config)
 416            .Select(config => new ProxyDeletionPayload(sweepId, config, null))];
 17
 18    /// <summary>Deletions of the selected orphans, each holding the ids of its scope's orphans.</summary>
 19    /// <param name="sweepId">The sweep.</param>
 20    /// <param name="selected">The selected orphans and their live configs.</param>
 21    public static IReadOnlyList<ProxyDeletionPayload> ForSelection(Guid sweepId, IEnumerable<ProxyOrphanScope> selected)
 522        => [.. InQueueOrder(selected.GroupBy(o => o.LiveStorageConfigId), group => group.Key)
 523            .Select(group => new ProxyDeletionPayload(sweepId, group.Key, [.. group.Select(o => o.Id)]))];
 24
 25    private static IOrderedEnumerable<T> InQueueOrder<T>(IEnumerable<T> scopes, Func<T, Guid?> configOf)
 926        => scopes.OrderBy(s => configOf(s) is null).ThenBy(configOf);
 27}