From 6ca6bfbc2e3dcdab978e32f69bd84d15f0c0f46b Mon Sep 17 00:00:00 2001 From: Mikhail Kuznetsov Date: Wed, 15 Jul 2026 16:27:00 +1000 Subject: [PATCH] =?UTF-8?q?refactor(aihitRelationshipsSyncer):=20=D0=A1?= =?UTF-8?q?=D1=82=D0=B8=D0=BB=D0=B8=D1=81=D1=82=D0=B8=D1=87=D0=B5=D1=81?= =?UTF-8?q?=D0=BA=D0=BE=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implementations/RelationshipsSyncService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PARR.AIHITRelationshipsSyncer/Services/Implementations/RelationshipsSyncService.cs b/PARR.AIHITRelationshipsSyncer/Services/Implementations/RelationshipsSyncService.cs index eed168fe..b8d744f9 100644 --- a/PARR.AIHITRelationshipsSyncer/Services/Implementations/RelationshipsSyncService.cs +++ b/PARR.AIHITRelationshipsSyncer/Services/Implementations/RelationshipsSyncService.cs @@ -145,7 +145,7 @@ internal class RelationshipsSyncService : IRelationshipsSyncService List<(string ParentName, string ChildName)> sourcePairs) { var relevantParentNames = sourcePairs.Select(p => p.ParentName).Distinct().ToList(); - + var existingForParents = await _unitRepository.Get() .AsNoTracking() .Include(u => u.ChildUnits).ThenInclude(r => r.ChildUnit) @@ -157,19 +157,19 @@ internal class RelationshipsSyncService : IRelationshipsSyncService Relationship = relationship }) .ToListAsync(); - + var sourceSet = new HashSet<(string, string)>(sourcePairs); var existingSet = new HashSet<(string, string)>( existingForParents.Select(x => (x.ParentName, x.ChildName))); - + var toRemove = existingForParents .Where(r => !sourceSet.Contains((r.ParentName, r.ChildName))) .ToList(); - + var toAdd = sourcePairs .Where(p => !existingSet.Contains(p)) .ToList(); - + _logger.LogInformation("Дельта: удаление {ToRemove}, добавление {ToAdd}", toRemove.Count, toAdd.Count); return (toRemove, toAdd); }