reafctor(templateMatcher): сервис синхронизации неактуальных шаблонов вынесен в отдельный класс
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.Core.Services.UnitFilterService;
|
||||
using PARR.TemplateMatcher.Exceptions;
|
||||
using PARR.TemplateMatcher.Services.GroupedSync;
|
||||
|
||||
namespace PARR.TemplateMatcher.Services.Implementations.GroupedSync;
|
||||
@@ -22,7 +23,7 @@ internal class FilterUnitsStage : IGroupedSyncStage
|
||||
var result = await _filterService.GetUnitsByJobFilterAsync(context.MaxJob.Id, null, ct);
|
||||
|
||||
if (result == null || !result.Any())
|
||||
throw new GroupedSyncEarlyExitException("Фильтры не дали Unit'ов с подходящими связями");
|
||||
throw new SyncEarlyExitException("Фильтры не дали Unit'ов с подходящими связями");
|
||||
|
||||
context.FilteredUnits = result.ToList();
|
||||
context.UnitNames = result.ToDictionary(u => u.Id, u => u.Name);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.TemplateMatcher.Exceptions;
|
||||
using PARR.TemplateMatcher.Services.GroupedSync;
|
||||
|
||||
namespace PARR.TemplateMatcher.Services.Implementations.GroupedSync;
|
||||
@@ -21,7 +22,7 @@ internal class GroupFilterStage : IGroupedSyncStage
|
||||
var finalFiltered = await _groupedFilter.FilterAsync(context.FilteredUnits, context.JobGroup);
|
||||
|
||||
if (!finalFiltered.Any())
|
||||
throw new GroupedSyncEarlyExitException("Нет юнитов после групповой фильтрации");
|
||||
throw new SyncEarlyExitException("Нет юнитов после групповой фильтрации");
|
||||
|
||||
context.FilteredUnits = finalFiltered;
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
namespace PARR.TemplateMatcher.Services.GroupedSync
|
||||
{
|
||||
/// <summary>
|
||||
/// Штатное прерывание пайплайна (нет данных после этапа).
|
||||
/// Не является ошибкой — оркестратор перехватывает и логирует как нормальное завершение.
|
||||
/// </summary>
|
||||
public class GroupedSyncEarlyExitException : Exception
|
||||
{
|
||||
public string Reason { get; }
|
||||
|
||||
public GroupedSyncEarlyExitException(string reason) : base(reason)
|
||||
{
|
||||
Reason = reason;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.Core.Repositories.Interfaces.JobGroupRepositories;
|
||||
using PARR.TemplateMatcher.Exceptions;
|
||||
using PARR.TemplateMatcher.Services.GroupedSync;
|
||||
|
||||
namespace PARR.TemplateMatcher.Services.Implementations.GroupedSync;
|
||||
@@ -32,7 +33,7 @@ internal class LoadJobGroupStage : IGroupedSyncStage
|
||||
.FirstOrDefaultAsync(jg => jg.Id == context.JobGroupId, ct);
|
||||
|
||||
if (jobGroup == null || jobGroup.Jobs == null || !jobGroup.Jobs.Any())
|
||||
throw new GroupedSyncEarlyExitException("JobGroup не найден или пуст");
|
||||
throw new SyncEarlyExitException("JobGroup не найден или пуст");
|
||||
|
||||
var jobsInGroup = jobGroup.Jobs.ToList();
|
||||
var maxJob = jobsInGroup
|
||||
@@ -41,7 +42,7 @@ internal class LoadJobGroupStage : IGroupedSyncStage
|
||||
.FirstOrDefault();
|
||||
|
||||
if (maxJob == null)
|
||||
throw new GroupedSyncEarlyExitException("Не найден Job с MaxValueRelationships");
|
||||
throw new SyncEarlyExitException("Не найден Job с MaxValueRelationships");
|
||||
|
||||
context.JobGroup = jobGroup;
|
||||
context.JobGroupName = jobGroup.GroupName;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.TemplateMatcher.Exceptions;
|
||||
using PARR.TemplateMatcher.Services.GroupedSync;
|
||||
|
||||
namespace PARR.TemplateMatcher.Services.Implementations.GroupedSync;
|
||||
@@ -21,7 +22,7 @@ internal class ResolveConflictsStage : IGroupedSyncStage
|
||||
var mapping = await _conflictMapper.BuildMappingAsync(context.FilteredUnits, context.MaxJob, ct);
|
||||
|
||||
if (!mapping.Any())
|
||||
throw new GroupedSyncEarlyExitException("Нет связей после разрешения конфликтов");
|
||||
throw new SyncEarlyExitException("Нет связей после разрешения конфликтов");
|
||||
|
||||
context.ReverseMapping = mapping;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user