mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-03-26 18:13:32 -04:00
fix per-instance search count during dry run
This commit is contained in:
@@ -80,10 +80,14 @@ public sealed class GeneralConfigController : ControllerBase
|
||||
.Where(d => !d.Strikes.Any())
|
||||
.ExecuteDeleteAsync();
|
||||
|
||||
var deletedHistory = await _dataContext.SeekerHistory
|
||||
.Where(h => h.IsDryRun)
|
||||
.ExecuteDeleteAsync();
|
||||
|
||||
_logger.LogWarning(
|
||||
"Dry run disabled — purged dry-run data: {Strikes} strikes, {Events} events, {ManualEvents} manual events, {Items} orphaned download items removed",
|
||||
deletedStrikes, deletedEvents, deletedManualEvents, deletedItems);
|
||||
|
||||
"Dry run disabled — purged dry-run data: {Strikes} strikes, {Events} events, {ManualEvents} manual events, {Items} orphaned download items, {History} search history entries removed",
|
||||
deletedStrikes, deletedEvents, deletedManualEvents, deletedItems, deletedHistory);
|
||||
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -325,11 +325,11 @@ public sealed class Seeker : IHandler
|
||||
_logger.LogInformation("Searched {Count} items on {InstanceName}: {Items}",
|
||||
searchItems.Count, arrInstance.Name, string.Join(", ", selectedNames));
|
||||
|
||||
// Update search history (always, so stats are accurate during dry run)
|
||||
await UpdateSearchHistoryAsync(arrInstance.Id, instanceType, instanceConfig.CurrentRunId, historyIds, selectedNames, seasonNumber, isDryRun);
|
||||
|
||||
if (!isDryRun)
|
||||
{
|
||||
// Update search history
|
||||
await UpdateSearchHistoryAsync(arrInstance.Id, instanceType, instanceConfig.CurrentRunId, historyIds, selectedNames, seasonNumber);
|
||||
|
||||
// Track commands
|
||||
long externalItemId = historyIds.FirstOrDefault();
|
||||
string itemTitle = selectedNames.FirstOrDefault() ?? string.Empty;
|
||||
@@ -635,7 +635,8 @@ public sealed class Seeker : IHandler
|
||||
Guid runId,
|
||||
List<long> searchedIds,
|
||||
List<string>? itemTitles = null,
|
||||
int seasonNumber = 0)
|
||||
int seasonNumber = 0,
|
||||
bool isDryRun = false)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
@@ -672,6 +673,7 @@ public sealed class Seeker : IHandler
|
||||
RunId = runId,
|
||||
LastSearchedAt = now,
|
||||
ItemTitle = title,
|
||||
IsDryRun = isDryRun,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,4 +60,9 @@ public sealed record SeekerHistory
|
||||
/// Running count of how many times this item has been searched
|
||||
/// </summary>
|
||||
public int SearchCount { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this history entry was created during a dry run
|
||||
/// </summary>
|
||||
public bool IsDryRun { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user