fix per-instance search count during dry run

This commit is contained in:
Flaminel
2026-03-23 11:14:31 +02:00
parent 4763a0624d
commit 96251ee4bb
3 changed files with 18 additions and 7 deletions

View File

@@ -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

View File

@@ -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,
});
}
}

View File

@@ -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; }
}