refactor: update CountHistoryQueryExtensions to use IEnumerable<EnvelopeStatus> and improve status handling

This commit is contained in:
tekh 2025-11-14 13:47:34 +01:00
parent b9c86ce3c6
commit 99e3e4c24d
3 changed files with 6 additions and 6 deletions

View File

@ -26,12 +26,12 @@ public static class CountHistoryQueryExtensions
/// <param name="statuses"></param> /// <param name="statuses"></param>
/// <param name="cancel"></param> /// <param name="cancel"></param>
/// <returns></returns> /// <returns></returns>
public static async Task<bool> AnyHistoryAsync(this ISender sender, string uuid, EnvelopeStatusQuery statuses, CancellationToken cancel = default) public static async Task<bool> AnyHistoryAsync(this ISender sender, string uuid, IEnumerable<EnvelopeStatus> statuses, CancellationToken cancel)
{ {
var count = await sender.Send(new CountHistoryQuery var count = await sender.Send(new CountHistoryQuery
{ {
Envelope = new() { Uuid = uuid }, Envelope = new() { Uuid = uuid },
Statuses = statuses Statuses = new() { Include = statuses }
}, cancel); }, cancel);
return count > 0; return count > 0;
} }
@ -89,7 +89,7 @@ public class CountHistoryQueryHandler : IRequestHandler<CountHistoryQuery, int>
if (status.Max is not null) if (status.Max is not null)
query = query.Where(er => er.Envelope!.Status <= status.Max); query = query.Where(er => er.Envelope!.Status <= status.Max);
if (status.Include?.Length > 0) if (status.Include?.Count() > 0)
query = query.Where(er => status.Include.Contains(er.Envelope!.Status)); query = query.Where(er => status.Include.Contains(er.Envelope!.Status));
if (status.Ignore is not null) if (status.Ignore is not null)

View File

@ -51,10 +51,10 @@ public record EnvelopeStatusQuery
/// <summary> /// <summary>
/// Eine Liste von Statuswerten, die einbezogen werden. /// Eine Liste von Statuswerten, die einbezogen werden.
/// </summary> /// </summary>
public EnvelopeStatus[]? Include { get; init; } public IEnumerable<EnvelopeStatus>? Include { get; init; }
/// <summary> /// <summary>
/// Eine Liste von Statuswerten, die ignoriert werden werden. /// Eine Liste von Statuswerten, die ignoriert werden werden.
/// </summary> /// </summary>
public EnvelopeStatus[]? Ignore { get; init; } public IEnumerable<EnvelopeStatus>? Ignore { get; init; }
} }

View File

@ -76,7 +76,7 @@ public class ReadHistoryQueryHandler : IRequestHandler<ReadHistoryQuery, IEnumer
if (status.Max is not null) if (status.Max is not null)
query = query.Where(er => er.Envelope!.Status <= status.Max); query = query.Where(er => er.Envelope!.Status <= status.Max);
if (status.Include?.Length > 0) if (status.Include?.Count() > 0)
query = query.Where(er => status.Include.Contains(er.Envelope!.Status)); query = query.Where(er => status.Include.Contains(er.Envelope!.Status));
if (status.Ignore is not null) if (status.Ignore is not null)