Вынести условия-предикаты в extension-методы

HasUser из 13 endpoint-файлов сведён в AuthHelpers.HasUser;
15 приватных предикатов заменены extension-методами с удалением
дублирующих приватных методов: IsCommunicationFailure,
IsTransportFailure, IsPrivateEndpoint, IsConfigured, IsTrue,
IsExpired, IsFailedLogin/IsSuccessfulLogin, HasChanges, HasBudget,
HasAnyTerm, IsCurrencyLetter, IsEmojiCodePoint, ContainsFooterHint,
IsTypeLabel.
This commit is contained in:
Rustam Khalimov
2026-09-11 13:08:47 +03:00
parent 9e07568ddd
commit 413eaac48c
40 changed files with 1091 additions and 993 deletions
@@ -0,0 +1,18 @@
using Deal.Modules.Discovery.Application.Models;
namespace Deal.Modules.Discovery.Application;
internal static class DiscoveryTaskPatchExtensions
{
/// <summary>
/// Содержит ли патч хотя бы одно изменяемое поле (python L289 «if not cols»).
/// </summary>
/// <param name="patch">Нормализованный патч.</param>
/// <returns>True — есть поле к записи.</returns>
public static bool HasChanges(this DiscoveryTaskPatch patch)
{
return patch.Name is not null || patch.Description is not null || patch.Keywords is not null
|| patch.MinSubscribers is not null || patch.Lang is not null || patch.Threshold is not null
|| patch.SampleSize is not null || patch.PlanJoins is not null || patch.AutoJoin is not null;
}
}
@@ -139,7 +139,7 @@ public sealed class DiscoveryTasksService(IDiscoveryStore store, DiscoveryPlanGu
}
}
if (!HasChanges(normalized))
if (!normalized.HasChanges())
{
// python L289290: пустой патч — возврат текущей задачи без записи (updated_at не бампается).
return current;
@@ -268,16 +268,6 @@ public sealed class DiscoveryTasksService(IDiscoveryStore store, DiscoveryPlanGu
};
}
// Проверка: патч содержит хотя бы одно изменяемое поле (python L289 «if not cols»).
// patch: Нормализованный патч.
// Возвращает: True — есть поле к записи.
private static bool HasChanges(DiscoveryTaskPatch patch)
{
return patch.Name is not null || patch.Description is not null || patch.Keywords is not null
|| patch.MinSubscribers is not null || patch.Lang is not null || patch.Threshold is not null
|| patch.SampleSize is not null || patch.PlanJoins is not null || patch.AutoJoin is not null;
}
// Очищает список ключей: Trim + без пустых (python L226227).
// keywords: Сырые ключи (null — пусто).
// Возвращает: Список непустых ключей.