From c41c394f48c4436b6a5ae811b0331287107dfc40 Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 4 Dec 2025 15:15:09 +0100 Subject: [PATCH] Refactor query handling for dynamic customization Updated `InvokeBatchRecActionsCommandExtensions` to filter actions with `Invoked = false` using a lambda in `ToReadQuery`. Refactored `ReadRecActionQueryBase` to remove the `Invoked` property and updated `ToReadQuery` to accept a delegate for external query modifications. Moved the `Invoked` property to `ReadRecActionQuery` and added a parameterless constructor. These changes improve flexibility and enable dynamic query customization. --- .../Commands/InvokeBatchRecActionsCommand.cs | 2 +- .../RecActions/Queries/ReadRecActionQuery.cs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionsCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionsCommand.cs index 2ed4b66..87770f7 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionsCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionsCommand.cs @@ -17,7 +17,7 @@ public class InvokeRecActionsCommandHandler(ISender sender, IServiceScopeFactory { public async Task Handle(InvokeBatchRecActionsCommand request, CancellationToken cancel) { - var actions = await sender.Send(request.ToReadQuery(), cancel); + var actions = await sender.Send(request.ToReadQuery(q => q.Invoked = false), cancel); var http = clientFactory.CreateClient(); diff --git a/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs b/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs index 9a3f656..9a248e0 100644 --- a/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs +++ b/src/ReC.Application/RecActions/Queries/ReadRecActionQuery.cs @@ -12,15 +12,20 @@ public record ReadRecActionQueryBase { public long ProfileId { get; init; } - public bool? Invoked { get; set; } = null; - - public ReadRecActionQuery ToReadQuery() => new(this); + public ReadRecActionQuery ToReadQuery(Action modify) + { + ReadRecActionQuery query = new(this); + modify(query); + return query; + } } public record ReadRecActionQuery : ReadRecActionQueryBase, IRequest> { public ReadRecActionQuery(ReadRecActionQueryBase root) : base(root) { } + public bool? Invoked { get; set; } = null; + public ReadRecActionQuery() { } }