PlotDirector/PlotLine/Models/PlotHealthModels.cs
Nick Beckley e48889ac05 Complete desktop workspaces, context menus and plot health
Commit the pending application, help and browser regression work. Pin the patched PKCS dependency for the production release.
2026-10-31 09:27:04 +00:00

49 lines
2.7 KiB
C#

namespace PlotLine.Models;
public enum PlotHealthLevel { Information, Review, Warning }
public sealed record PlotHealthScope(int ProjectID, int? BookID, int? ScenarioID, int CutoffPosition,
int SceneCount, bool EvidenceComplete, int MissingSceneCount)
{
public string OrderLabel => ScenarioID.HasValue ? $"Scenario {ScenarioID}" : "Canonical manuscript";
public string ScopeLabel => BookID.HasValue ? $"Book {BookID}" : "Current project";
}
public sealed record PlotHealthEvidence(int SceneID, int Position, int BookID, int ChapterID,
string SceneTitle, string Signal, int? ThreadEventID = null);
public sealed record PlotHealthFinding(string RuleID, PlotHealthLevel Level, int PlotLineID, int? PlotThreadID,
string Title, string Explanation, string StoredStatus, IReadOnlyList<PlotHealthEvidence> Evidence,
PlotHealthScope Scope, int? MarkerSceneID, int? ScenesWithoutProgress = null, int? ChaptersWithoutProgress = null)
{
public string EntityType => PlotThreadID.HasValue ? "PlotThread" : "PlotLine";
public bool EvidenceComplete => Scope.EvidenceComplete;
}
public sealed record PlotThreadHealth(int PlotLineID, int PlotThreadID, string ThreadTitle, string StoredStatus,
IReadOnlyList<string> ObservedSignals, PlotHealthEvidence? FirstTouch, PlotHealthEvidence? LastTouch,
PlotHealthEvidence? LastProgress, int LeadingScenes, int? ScenesSinceTouch, int? ChaptersSinceTouch,
int? ScenesSinceProgress, int? ChaptersSinceProgress, IReadOnlyList<PlotHealthFinding> Findings);
public sealed record PlotLineHealth(int PlotLineID, IReadOnlyList<PlotThreadHealth> Threads,
IReadOnlyList<PlotHealthFinding> Findings)
{
public int InformationCount => Findings.Count(f => f.Level == PlotHealthLevel.Information);
public int ReviewCount => Findings.Count(f => f.Level == PlotHealthLevel.Review);
public int WarningCount => Findings.Count(f => f.Level == PlotHealthLevel.Warning);
public string Summary => string.Join(" · ", new[] {
WarningCount > 0 ? $"{WarningCount} warning" : null,
ReviewCount > 0 ? $"{ReviewCount} review" : null,
InformationCount > 0 ? $"{InformationCount} info" : null }.Where(x => x is not null));
}
public sealed record PlotHealthResult(PlotHealthScope Scope, IReadOnlyList<PlotLineHealth> Lines)
{
public static PlotHealthResult Empty { get; } = new(new(0, null, null, 0, 0, true, 0), []);
public IReadOnlyList<PlotHealthFinding> Findings => Lines.SelectMany(l => l.Findings).ToList();
}
public sealed record PlotHealthContext(int ProjectID, int? BookID, int? ScenarioID,
IReadOnlyCollection<int> SelectedLineIDs, PlotLineWorkspaceData Data,
PlotLineWorkspaceData ReferenceData, int? CutoffPosition = null);