From 1b9d8d23863debf980500afabd086f01d37180e7 Mon Sep 17 00:00:00 2001 From: jimwashbrook <131891854+jimwashbrook@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:14:11 +0000 Subject: [PATCH] fix: no longer duplicate content (#550) * fix: no longer duplicate content Code was basically doing a full outer join, instead of a left join, resulting in content being duplicated multiple times. * fix: take latest pagecontent if applicable * fix: remove old css file --- .../Content/Models/PageDbEntity.cs | 8 ++++---- src/Dfe.PlanTech.Web/Views/Shared/_Layout.cshtml | 15 +++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Dfe.PlanTech.Domain/Content/Models/PageDbEntity.cs b/src/Dfe.PlanTech.Domain/Content/Models/PageDbEntity.cs index 3dd9d6fdf..00982909c 100644 --- a/src/Dfe.PlanTech.Domain/Content/Models/PageDbEntity.cs +++ b/src/Dfe.PlanTech.Domain/Content/Models/PageDbEntity.cs @@ -44,14 +44,14 @@ public void OrderContents() } private IEnumerable OrderContents(List contents, Func idSelector) - => contents.Join(AllPageContents, + => contents.GroupJoin(AllPageContents, content => content.Id, idSelector, (content, pageContent) => new { content, - order = pageContent.Order + order = pageContent.OrderByDescending(pc => pc.Id).Select(join => join.Order).First() }) - .OrderBy(content => content.order) - .Select(content => content.content); + .OrderBy(joined => joined.order) + .Select(joined => joined.content); } \ No newline at end of file diff --git a/src/Dfe.PlanTech.Web/Views/Shared/_Layout.cshtml b/src/Dfe.PlanTech.Web/Views/Shared/_Layout.cshtml index f83dd0bb3..c9882b78f 100644 --- a/src/Dfe.PlanTech.Web/Views/Shared/_Layout.cshtml +++ b/src/Dfe.PlanTech.Web/Views/Shared/_Layout.cshtml @@ -6,11 +6,10 @@ @section Head { - - @Html.Raw(GtmConfiguration.Analytics) - @Html.Raw(GtmConfiguration.Head) - @RenderSection("Head", false) + @Html.Raw(GtmConfiguration.Analytics) + @Html.Raw(GtmConfiguration.Head) + @RenderSection("Head", false) } @{ @@ -31,19 +30,19 @@ await Html.RenderPartialAsync("_Header"); } - @RenderSection("Header", false) +@RenderSection("Header", false) } @section BeforeContent { @{ await Html.RenderPartialAsync("BetaHeader"); } - @RenderSection("BeforeContent", required: false) +@RenderSection("BeforeContent", required: false) - @{ +@{ //Add relevant tags for GovUK front-end CSS to body } - + }