perf(templateengine): alarm-override, folder-delete and template-delete checks read lean template projections (review 2026-10-21 04/P6, 08/P1)

InstanceService.SetAlarmOverrideAsync and TemplateDeletionService move to the
no-tracking, body-free GetAllTemplatesForAnalysisAsync; TemplateFolderService
counts folder contents from GetTemplateStubsAsync.
This commit is contained in:
Joseph Doherty
2026-10-22 06:25:16 -04:00
parent 7d11a1db8d
commit c7774b7ec2
7 changed files with 54 additions and 29 deletions
@@ -53,7 +53,10 @@ public class TemplateDeletionService
}
// Check 2: Child templates reference it as parent. Split derived vs. regular.
var allTemplates = await _repository.GetAllTemplatesAsync(cancellationToken);
// Reads ids, names, parent/derived/owner edges and composition rows only — the
// no-tracking, script-body-free analysis projection carries all of them
// (review 2026-10-21 04/P6, 08/P1).
var allTemplates = await _repository.GetAllTemplatesForAnalysisAsync(cancellationToken);
var inheritors = allTemplates.Where(t => t.ParentTemplateId == templateId).ToList();
var regularChildren = inheritors.Where(t => !t.IsDerived).ToList();
var derivatives = inheritors.Where(t => t.IsDerived).ToList();
@@ -79,7 +82,7 @@ public class TemplateDeletionService
}
// Check 3: Other templates compose it directly.
// Read the Compositions navigation already loaded by GetAllTemplatesAsync
// Read the Compositions navigation already loaded by GetAllTemplatesForAnalysisAsync
// rather than issuing one GetCompositionsByTemplateIdAsync round-trip per
// template — this is the same source TemplateService
// .DeleteTemplateAsync uses for the equivalent check.