mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-10-28 02:38:55 -04:00
added funnel counts to search stats summary
This commit is contained in:
1 parent
f86c708e77
commit
8d88ba4bf7
3 files changed
+42
No files matched your search
@@ -0,0 +1,40 @@
|
||||
using Cleanuparr.Persistence.Models.State;
|
||||
|
||||
namespace Cleanuparr.Api.Features.Seeker.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// How many items and units survived each Seeker stage on the cycle's latest run.
|
||||
/// Items count movies or series, units count searches.
|
||||
/// </summary>
|
||||
public sealed record InstanceFunnelStat
|
||||
{
|
||||
public int LibraryItems { get; init; }
|
||||
public int ReleasedItems { get; init; }
|
||||
public int MonitoredItems { get; init; }
|
||||
public int TagFilteredItems { get; init; }
|
||||
public int EligibleUnits { get; init; }
|
||||
public int QueuedUnits { get; init; }
|
||||
public int RecentlyGrabbedUnits { get; init; }
|
||||
public int SearchedUnits { get; init; }
|
||||
public int RemainingUnits { get; init; }
|
||||
public DateTimeOffset CountedAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Null until a run counted the cycle's funnel.
|
||||
/// </summary>
|
||||
public static InstanceFunnelStat? From(SeekerCycle? cycle) => cycle?.FunnelCountedAt is not { } countedAt
|
||||
? null
|
||||
: new InstanceFunnelStat
|
||||
{
|
||||
LibraryItems = cycle.LibraryItems,
|
||||
ReleasedItems = cycle.ReleasedItems,
|
||||
MonitoredItems = cycle.MonitoredItems,
|
||||
TagFilteredItems = cycle.TagFilteredItems,
|
||||
EligibleUnits = cycle.EligibleNow,
|
||||
QueuedUnits = cycle.QueuedUnits,
|
||||
RecentlyGrabbedUnits = cycle.RecentlyGrabbedUnits,
|
||||
SearchedUnits = Math.Max(0, cycle.EligibleNow - cycle.QueuedUnits - cycle.RecentlyGrabbedUnits - cycle.RemainingUnits),
|
||||
RemainingUnits = cycle.RemainingUnits,
|
||||
CountedAt = countedAt,
|
||||
};
|
||||
}
|
||||
@@ -17,4 +17,5 @@ public sealed record InstanceSearchStat
|
||||
public DateTimeOffset? CycleCompletedAt { get; init; }
|
||||
public DateTimeOffset? LastCycleStartedAt { get; init; }
|
||||
public DateTimeOffset? LastCycleCompletedAt { get; init; }
|
||||
public InstanceFunnelStat? Funnel { get; init; }
|
||||
}
|
||||
@@ -111,6 +111,7 @@ public sealed class SearchStatsController : ControllerBase
|
||||
CycleCompletedAt = current?.CompletedAt,
|
||||
LastCycleStartedAt = last?.StartedAt,
|
||||
LastCycleCompletedAt = last?.CompletedAt,
|
||||
Funnel = InstanceFunnelStat.From(current),
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
|
||||
Reference in new issue
Block a user