< Summary - Jellyfin

Information
Class: Jellyfin.Database.Implementations.ProgressablePartitionReporting<T>
Assembly: Jellyfin.Database.Implementations
File(s): /srv/git/jellyfin/src/Jellyfin.Database/Jellyfin.Database.Implementations/ProgressablePartitionReporting.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 55
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
get_Source()100%210%
BeginItem(...)0%620%
BeginPartition(...)0%620%
EndItem(...)0%620%
EndPartition(...)0%620%

File(s)

/srv/git/jellyfin/src/Jellyfin.Database/Jellyfin.Database.Implementations/ProgressablePartitionReporting.cs

#LineLine coverage
 1using System;
 2using System.Diagnostics;
 3using System.Linq;
 4
 5namespace Jellyfin.Database.Implementations;
 6
 7/// <summary>
 8/// Wrapper for progress reporting on Partition helpers.
 9/// </summary>
 10/// <typeparam name="TEntity">The entity to load.</typeparam>
 11public class ProgressablePartitionReporting<TEntity>
 12{
 13    private readonly IOrderedQueryable<TEntity> _source;
 14
 015    private readonly Stopwatch _partitionTime = new();
 16
 017    private readonly Stopwatch _itemTime = new();
 18
 19    internal ProgressablePartitionReporting(IOrderedQueryable<TEntity> source)
 20    {
 021        _source = source;
 022    }
 23
 24    internal Action<TEntity, int, int>? OnBeginItem { get; set; }
 25
 26    internal Action<int>? OnBeginPartition { get; set; }
 27
 28    internal Action<TEntity, int, int, TimeSpan>? OnEndItem { get; set; }
 29
 30    internal Action<int, TimeSpan>? OnEndPartition { get; set; }
 31
 032    internal IOrderedQueryable<TEntity> Source => _source;
 33
 34    internal void BeginItem(TEntity entity, int iteration, int itemIndex)
 35    {
 036        _itemTime.Restart();
 037        OnBeginItem?.Invoke(entity, iteration, itemIndex);
 038    }
 39
 40    internal void BeginPartition(int iteration)
 41    {
 042        _partitionTime.Restart();
 043        OnBeginPartition?.Invoke(iteration);
 044    }
 45
 46    internal void EndItem(TEntity entity, int iteration, int itemIndex)
 47    {
 048        OnEndItem?.Invoke(entity, iteration, itemIndex, _itemTime.Elapsed);
 049    }
 50
 51    internal void EndPartition(int iteration)
 52    {
 053        OnEndPartition?.Invoke(iteration, _partitionTime.Elapsed);
 054    }
 55}