diff --git a/src/Forte.Optimizely.ContentUsage/Api/Features/ContentType/ContentTypeUsagesRepository.cs b/src/Forte.Optimizely.ContentUsage/Api/Features/ContentType/ContentTypeUsagesRepository.cs index abcb5ee..28a5ae7 100644 --- a/src/Forte.Optimizely.ContentUsage/Api/Features/ContentType/ContentTypeUsagesRepository.cs +++ b/src/Forte.Optimizely.ContentUsage/Api/Features/ContentType/ContentTypeUsagesRepository.cs @@ -9,17 +9,17 @@ namespace Forte.Optimizely.ContentUsage.Api.Features.ContentType; public class ContentTypeUsagesRepository { - private readonly ServiceAccessor dataExecutorAccessor; + private readonly ServiceAccessor _dataExecutorAccessor; public ContentTypeUsagesRepository(ServiceAccessor dataExecutorAccessor) { - this.dataExecutorAccessor = dataExecutorAccessor; + _dataExecutorAccessor = dataExecutorAccessor; } public async Task> ListContentTypesUsagesCounters( CancellationToken cancellationToken) { - var executor = this.dataExecutorAccessor(); + var executor = _dataExecutorAccessor(); return await executor.ExecuteAsync((Func>>)(async () => { var command1 = executor.CreateCommand(); diff --git a/src/Forte.Optimizely.ContentUsage/Api/Services/ContentTypeService.cs b/src/Forte.Optimizely.ContentUsage/Api/Services/ContentTypeService.cs index c18f6ea..2ab222b 100644 --- a/src/Forte.Optimizely.ContentUsage/Api/Services/ContentTypeService.cs +++ b/src/Forte.Optimizely.ContentUsage/Api/Services/ContentTypeService.cs @@ -11,13 +11,13 @@ namespace Forte.Optimizely.ContentUsage.Api.Services; public class ContentTypeService { private readonly IContentTypeRepository _contentTypeRepository; - private readonly ContentTypeUsagesRepository contentTypeUsagesRepository; + private readonly ContentTypeUsagesRepository _contentTypeUsagesRepository; public ContentTypeService(IContentTypeRepository contentTypeRepository, ContentTypeUsagesRepository contentTypeUsagesRepository) { _contentTypeRepository = contentTypeRepository; - this.contentTypeUsagesRepository = contentTypeUsagesRepository; + _contentTypeUsagesRepository = contentTypeUsagesRepository; } public IEnumerable GetAll(ContentTypesFilterCriteria? filterCriteria) @@ -34,7 +34,7 @@ public IEnumerable GetAll(ContentTypesFilterCriteria? filterCriteri public async Task> GetAllCounters(CancellationToken cancellationToken) { - return await contentTypeUsagesRepository.ListContentTypesUsagesCounters(cancellationToken); + return await _contentTypeUsagesRepository.ListContentTypesUsagesCounters(cancellationToken); } public ContentType? Get(Guid guid) diff --git a/src/Forte.Optimizely.ContentUsage/Api/Services/ContentUsageService.cs b/src/Forte.Optimizely.ContentUsage/Api/Services/ContentUsageService.cs index 97a13d7..a58b8f1 100644 --- a/src/Forte.Optimizely.ContentUsage/Api/Services/ContentUsageService.cs +++ b/src/Forte.Optimizely.ContentUsage/Api/Services/ContentUsageService.cs @@ -32,17 +32,28 @@ public ContentUsageService(IUrlResolver urlResolver, IContentSoftLinkRepository public IEnumerable GetPageUrls(EPiServerContentUsage contentUsage) { var contentLink = contentUsage.ContentLink; - var url = _urlResolver.GetUrl(contentLink, contentUsage.LanguageBranch); + + var pageUrls = SearchForPageUrls(contentLink, contentUsage.LanguageBranch); + + return pageUrls; + } + + private IEnumerable SearchForPageUrls(ContentReference contentLink, string languageBranch) + { + var url = _urlResolver.GetUrl(contentLink, languageBranch); if (!string.IsNullOrEmpty(url)) return CheckIsPublished(contentLink) ? new[] { url } : new string[] { }; - var pageLinks = _contentSoftLinkRepository.Load(contentLink, true) + var softLinks = _contentSoftLinkRepository.Load(contentLink, true); + var pageLinks = softLinks .Where(softLink => softLink.SoftLinkType == ReferenceType.PageLinkReference) .Select(softLink => softLink.OwnerContentLink) .Where(ownerContentLink => ownerContentLink != null && CheckIsPublished(ownerContentLink)); - return pageLinks.Select(pageLink => _urlResolver.GetUrl(pageLink, contentUsage.LanguageBranch)); + var pageUrls = pageLinks.SelectMany(pageLink => SearchForPageUrls(pageLink, languageBranch)); + + return pageUrls; } public string GetEditUrl(EPiServerContentUsage contentUsage)