< Summary

Information
Class: Chronicis.Api.Services.HierarchyWalkOptions
Assembly: Chronicis.Api
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Api/Services/IArticleHierarchyService.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 77
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_PublicOnly()100%11100%
get_IncludeWorldBreadcrumb()100%11100%
get_IncludeVirtualGroups()100%11100%
get_IncludeCurrentArticle()100%11100%
get_World()100%11100%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Api/Services/IArticleHierarchyService.cs

#LineLine coverage
 1using Chronicis.Shared.DTOs;
 2
 3namespace Chronicis.Api.Services;
 4
 5/// <summary>
 6/// Centralised service for walking article parent hierarchies.
 7/// Replaces duplicated parent-walk logic formerly in ArticleService,
 8/// PublicWorldService, SearchController, ArticlesController, and WorldsController.
 9/// </summary>
 10public interface IArticleHierarchyService
 11{
 12    /// <summary>
 13    /// Build an ordered breadcrumb trail from the root (optionally including the world)
 14    /// down to the specified article.
 15    /// </summary>
 16    Task<List<BreadcrumbDto>> BuildBreadcrumbsAsync(Guid articleId, HierarchyWalkOptions? options = null);
 17
 18    /// <summary>
 19    /// Build a slash-separated path string from slugs (e.g. "world-slug/parent-slug/child-slug").
 20    /// Convenience wrapper around <see cref="BuildBreadcrumbsAsync"/>.
 21    /// </summary>
 22    Task<string> BuildPathAsync(Guid articleId, HierarchyWalkOptions? options = null);
 23
 24    /// <summary>
 25    /// Build a human-readable display path of titles joined with " / ".
 26    /// Optionally strips the first level (world root) for display in link suggestions / backlinks.
 27    /// </summary>
 28    Task<string> BuildDisplayPathAsync(Guid articleId, bool stripFirstLevel = true);
 29}
 30
 31/// <summary>
 32/// Options that control how the hierarchy walk behaves.
 33/// </summary>
 34public class HierarchyWalkOptions
 35{
 36    /// <summary>
 37    /// When true, only articles with Public visibility are included in the walk.
 38    /// If a non-public article is encountered mid-chain the walk stops.
 39    /// </summary>
 4240    public bool PublicOnly { get; set; } = false;
 41
 42    /// <summary>
 43    /// When true, a World breadcrumb is prepended to the result.
 44    /// Requires the target article to have a WorldId.
 45    /// </summary>
 3546    public bool IncludeWorldBreadcrumb { get; set; } = true;
 47
 48    /// <summary>
 49    /// When true, virtual group breadcrumbs (Campaigns, Player Characters, Wiki)
 50    /// are inserted between the World breadcrumb and the article chain.
 51    /// Only meaningful when <see cref="IncludeWorldBreadcrumb"/> is also true.
 52    /// </summary>
 2053    public bool IncludeVirtualGroups { get; set; } = false;
 54
 55    /// <summary>
 56    /// When true (default), the target article itself is included as the last breadcrumb.
 57    /// Set to false when you only need the ancestor chain above the article.
 58    /// </summary>
 3759    public bool IncludeCurrentArticle { get; set; } = true;
 60
 61    /// <summary>
 62    /// Pre-resolved world metadata. When supplied, skips the world lookup query.
 63    /// Required when <see cref="IncludeVirtualGroups"/> is true.
 64    /// </summary>
 2965    public WorldContext? World { get; set; }
 66}
 67
 68/// <summary>
 69/// Pre-resolved world information to avoid redundant DB lookups
 70/// when the caller already has it.
 71/// </summary>
 72public class WorldContext
 73{
 74    public Guid Id { get; set; }
 75    public string Name { get; set; } = string.Empty;
 76    public string Slug { get; set; } = string.Empty;
 77}