Skip to content

Commit

Permalink
fix: no longer duplicate content (#550)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jimwashbrook authored Feb 29, 2024
1 parent e32cf59 commit 1b9d8d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/Dfe.PlanTech.Domain/Content/Models/PageDbEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public void OrderContents()
}

private IEnumerable<ContentComponentDbEntity> OrderContents(List<ContentComponentDbEntity> contents, Func<PageContentDbEntity, string?> 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);
}
15 changes: 7 additions & 8 deletions src/Dfe.PlanTech.Web/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

@section Head {
<link rel="stylesheet" href="~/css/application.css">
<link rel="stylesheet" href="~/css/govuk-frontend.min.css">

@Html.Raw(GtmConfiguration.Analytics)
@Html.Raw(GtmConfiguration.Head)
@RenderSection("Head", false)
@Html.Raw(GtmConfiguration.Analytics)
@Html.Raw(GtmConfiguration.Head)
@RenderSection("Head", false)
}

@{
Expand All @@ -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
}
<script>document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' govuk-frontend-supported' : '');</script>
<script>document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' govuk-frontend-supported' : '');</script>
}


Expand Down

0 comments on commit 1b9d8d2

Please sign in to comment.