-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #900 from DFE-Digital/feat/234320/unified-contentf…
…ul-retrieval feat: unified Contentful retrieval
- Loading branch information
Showing
111 changed files
with
504 additions
and
817 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/Dfe.PlanTech.Application/Content/Queries/GetContentSupportPageQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Dfe.PlanTech.Application.Caching.Interfaces; | ||
using Dfe.PlanTech.Application.Exceptions; | ||
using Dfe.PlanTech.Application.Persistence.Interfaces; | ||
using Dfe.PlanTech.Application.Persistence.Models; | ||
using Dfe.PlanTech.Domain.Content.Models.ContentSupport; | ||
using Dfe.PlanTech.Domain.Content.Queries; | ||
using Dfe.PlanTech.Infrastructure.Application.Models; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Dfe.PlanTech.Application.Content.Queries; | ||
public record GetContentSupportPageQuery( | ||
ICmsCache Cache, | ||
IContentRepository Repository, | ||
ILogger<GetContentSupportPageQuery> Logger) : IGetContentSupportPageQuery | ||
{ | ||
public async Task<ContentSupportPage?> GetContentSupportPage(string slug, CancellationToken cancellationToken = default) | ||
{ | ||
try | ||
{ | ||
var pages = await Cache.GetOrCreateAsync($"ContentSupportPage:{slug}", () => Repository.GetEntities<ContentSupportPage>(CreateGetEntityOptions(slug), cancellationToken)) ?? []; | ||
|
||
var page = pages.FirstOrDefault(); | ||
|
||
return page; | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.LogError(ex, "Error fetching content support page {slug} from Contentful", slug); | ||
throw new ContentfulDataUnavailableException($"Could not retrieve content support page with slug {slug}", ex); | ||
} | ||
} | ||
|
||
private GetEntitiesOptions CreateGetEntityOptions(string slug) => new(10, [new ContentQueryEquals() { Field = "fields.Slug", Value = slug }]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Dfe.PlanTech.Domain/Content/Interfaces/IGetContentSupportPageQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Dfe.PlanTech.Domain.Content.Models.ContentSupport; | ||
|
||
namespace Dfe.PlanTech.Domain.Content.Queries; | ||
|
||
/// <summary> | ||
/// Retrieves a page from contentful | ||
/// </summary> | ||
public interface IGetContentSupportPageQuery | ||
{ | ||
/// <summary> | ||
/// Fetches content support page from <see chref="IContentRepository"/> by slug | ||
/// </summary> | ||
/// <param name="slug">Slug for the C&S Page</param> | ||
/// <returns>ContentSupportPage matching slug</returns> | ||
Task<ContentSupportPage?> GetContentSupportPage(string slug, CancellationToken cancellationToken = default); | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
src/Dfe.PlanTech.Domain/Content/Models/ContentSupport/CSBodyText.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Dfe.PlanTech.Domain.Content.Models.ContentSupport; | ||
|
||
[ExcludeFromCodeCoverage] | ||
public class CSBodyText : Target; |
6 changes: 6 additions & 0 deletions
6
src/Dfe.PlanTech.Domain/Content/Models/ContentSupport/CSHeading.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Dfe.PlanTech.Domain.Content.Models.ContentSupport; | ||
|
||
[ExcludeFromCodeCoverage] | ||
public class CSHeading : ContentBase; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...lanTech.Web/Models/Content/ContentItem.cs → ...tent/Models/ContentSupport/ContentItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Contentful.Core.Models; | ||
|
||
namespace Dfe.PlanTech.Web.Models.Content; | ||
namespace Dfe.PlanTech.Domain.Content.Models.ContentSupport; | ||
|
||
[ExcludeFromCodeCoverage] | ||
public class ContentItem : ContentItemBase | ||
{ | ||
public string Value { get; set; } = null!; | ||
public List<Mark> Marks { get; set; } = []; | ||
public Data Data { get; set; } = null!; | ||
} |
2 changes: 1 addition & 1 deletion
2
...ech.Web/Models/Content/ContentItemBase.cs → .../Models/ContentSupport/ContentItemBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
....Web/Models/Content/ContentSupportPage.cs → ...dels/ContentSupport/ContentSupportPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lanTech.Web/Models/Content/ContentType.cs → ...tent/Models/ContentSupport/ContentType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Dfe.PlanTech.Web/Models/Content/Data.cs → ...ain/Content/Models/ContentSupport/Data.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/Dfe.PlanTech.Web/Models/Content/Entry.cs → ...in/Content/Models/ContentSupport/Entry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Dfe.PlanTech.Web/Models/Content/Fields.cs → ...n/Content/Models/ContentSupport/Fields.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lanTech.Web/Models/Content/FileDetails.cs → ...tent/Models/ContentSupport/FileDetails.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Dfe.PlanTech.Web/Models/Content/Image.cs → ...in/Content/Models/ContentSupport/Image.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...eb/Models/Content/Mapped/CsContentItem.cs → ...ls/ContentSupport/Mapped/CsContentItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Dfe.PlanTech.Domain.Content.Interfaces; | ||
|
||
namespace Dfe.PlanTech.Web.Models.Content.Mapped; | ||
namespace Dfe.PlanTech.Domain.Content.Models.ContentSupport.Mapped; | ||
|
||
[ExcludeFromCodeCoverage] | ||
public class CsContentItem | ||
public class CsContentItem : IContentComponent | ||
{ | ||
public string InternalName { get; set; } = null!; | ||
public string Slug { get; set; } = null!; | ||
public string? Title { get; set; } = null; | ||
public string? Subtitle { get; set; } = null; | ||
public bool UseParentHero { get; set; } | ||
|
||
public SystemDetails Sys { get; set; } = new SystemDetails(); | ||
} |
6 changes: 3 additions & 3 deletions
6
...nTech.Web/Models/Content/Mapped/CsPage.cs → ...nt/Models/ContentSupport/Mapped/CsPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../Content/Mapped/Custom/CustomAccordion.cs → ...tSupport/Mapped/Custom/CustomAccordion.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...Content/Mapped/Custom/CustomAttachment.cs → ...Support/Mapped/Custom/CustomAttachment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...odels/Content/Mapped/Custom/CustomCard.cs → ...ontentSupport/Mapped/Custom/CustomCard.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../Content/Mapped/Custom/CustomComponent.cs → ...tSupport/Mapped/Custom/CustomComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...tent/Mapped/Custom/CustomGridContainer.cs → ...port/Mapped/Custom/CustomGridContainer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/Dfe.PlanTech.Domain/Content/Models/ContentSupport/Mapped/PageLink.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Dfe.PlanTech.Domain.Content.Models.ContentSupport.Mapped; | ||
public class PageLink | ||
{ | ||
public string? Title { get; set; } = null; | ||
public string? Subtitle { get; set; } = null; | ||
public required string Url { get; set; } | ||
public required bool IsActive { get; set; } | ||
} |
4 changes: 2 additions & 2 deletions
4
...els/Content/Mapped/RichTextContentItem.cs → ...tentSupport/Mapped/RichTextContentItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../Models/Content/Mapped/Standard/CsText.cs → .../ContentSupport/Mapped/Standard/CsText.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../Content/Mapped/Standard/EmbeddedAsset.cs → ...tSupport/Mapped/Standard/EmbeddedAsset.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
.../Content/Mapped/Standard/EmbeddedEntry.cs → ...tSupport/Mapped/Standard/EmbeddedEntry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...dels/Content/Mapped/Standard/Hyperlink.cs → ...ntentSupport/Mapped/Standard/Hyperlink.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/Dfe.PlanTech.Domain/Content/Models/ContentSupport/Mapped/Types/AssetContentType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Dfe.PlanTech.Domain.Content.Models.ContentSupport.Mapped.Types; | ||
|
||
public enum AssetContentType | ||
{ | ||
Unknown, | ||
Image, | ||
Video | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Dfe.PlanTech.Domain/Content/Models/ContentSupport/Mapped/Types/CustomComponentType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Dfe.PlanTech.Domain.Content.Models.ContentSupport.Mapped.Types; | ||
|
||
public enum CustomComponentType | ||
{ | ||
Undefined, | ||
Accordion, | ||
Attachment, | ||
Card, | ||
GridContainer, | ||
CSAccordion, | ||
csCard, | ||
AccordionSection, | ||
csJumpLinkComponent | ||
} |
2 changes: 1 addition & 1 deletion
2
.../Content/Mapped/Types/RichTextNodeType.cs → ...tSupport/Mapped/Types/RichTextNodeType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/Dfe.PlanTech.Web/Models/Content/Sys.cs → ...main/Content/Models/ContentSupport/Sys.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.