fix(deployment): flatten reads compositions off the loaded template instead of a second per-template query (review 2026-10-21 04/U5)

This commit is contained in:
Joseph Doherty
2026-10-22 06:32:32 -04:00
parent 669822772e
commit 7975699ac4
6 changed files with 25 additions and 8 deletions
@@ -240,9 +240,14 @@ public class FlatteningPipeline : IFlatteningPipeline
{
if (!processedTemplateIds.Add(template.Id)) continue;
// The chain's templates come from GetTemplateWithChildrenAsync, which already
// Includes Compositions — read them off the loaded entity rather than issuing a
// second per-template composition query.
var loaded = template;
var compositions = await session.GetCompositionsAsync(
template.Id,
id => _templateRepo.GetCompositionsByTemplateIdAsync(id, cancellationToken));
_ => Task.FromResult<IReadOnlyList<Commons.Entities.Templates.TemplateComposition>>(
loaded.Compositions.ToList()));
if (compositions.Count == 0) continue;
compositionMap[template.Id] = compositions;