refactor(aihitRelationshipsSyncer): Стилистическое изменение

This commit is contained in:
Mikhail Kuznetsov
2026-07-15 16:27:00 +10:00
parent 178a991d8b
commit 6ca6bfbc2e

View File

@@ -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);
}