|
| 1 | +namespace Sigtran.NET.Core.Utilities; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Describes the commercial evidence dossier intake report. |
| 5 | +/// </summary> |
| 6 | +public sealed class SigtranCommercialEvidenceDossierIntakeReport |
| 7 | +{ |
| 8 | + /// <summary>Creates a commercial evidence dossier intake report.</summary> |
| 9 | + /// <param name="completeness">The artifact completeness result.</param> |
| 10 | + /// <param name="reportPath">The retained report path.</param> |
| 11 | + public SigtranCommercialEvidenceDossierIntakeReport( |
| 12 | + SigtranCommercialEvidenceArtifactCompletenessResult completeness, |
| 13 | + string reportPath) |
| 14 | + { |
| 15 | + Completeness = completeness ?? throw new ArgumentNullException(nameof(completeness)); |
| 16 | + ReportPath = string.IsNullOrWhiteSpace(reportPath) ? throw new ArgumentException("Report path is required.", nameof(reportPath)) : reportPath; |
| 17 | + } |
| 18 | + |
| 19 | + /// <summary>The artifact completeness result.</summary> |
| 20 | + public SigtranCommercialEvidenceArtifactCompletenessResult Completeness { get; } |
| 21 | + |
| 22 | + /// <summary>The retained report path.</summary> |
| 23 | + public string ReportPath { get; } |
| 24 | + |
| 25 | + /// <summary>The artifact intake target.</summary> |
| 26 | + public SigtranCommercialEvidenceArtifactIntakeTarget Target => Completeness.RedactionReviewManifest.DigestManifest.SourceManifest.Target; |
| 27 | + |
| 28 | + /// <summary>The number of registered artifact sources.</summary> |
| 29 | + public int SourceCount => Completeness.RedactionReviewManifest.DigestManifest.SourceManifest.Sources.Count; |
| 30 | + |
| 31 | + /// <summary>The number of digest entries.</summary> |
| 32 | + public int DigestCount => Completeness.RedactionReviewManifest.DigestManifest.Digests.Count; |
| 33 | + |
| 34 | + /// <summary>The number of redaction reviews.</summary> |
| 35 | + public int RedactionReviewCount => Completeness.RedactionReviewManifest.Reviews.Count; |
| 36 | + |
| 37 | + /// <summary>Whether the report path is scoped under the dossier root.</summary> |
| 38 | + public bool UsesDossierReportPath => ReportPath.StartsWith(Target.DossierRoot + "/", StringComparison.Ordinal); |
| 39 | + |
| 40 | + /// <summary>Whether the report is ready for retention.</summary> |
| 41 | + public bool IsReady => Completeness.IsComplete |
| 42 | + && UsesDossierReportPath |
| 43 | + && SourceCount > 0 |
| 44 | + && DigestCount == SourceCount; |
| 45 | + |
| 46 | + /// <summary>Renders the report as Markdown.</summary> |
| 47 | + /// <returns>The rendered Markdown report.</returns> |
| 48 | + public string RenderMarkdown() |
| 49 | + { |
| 50 | + return string.Join( |
| 51 | + Environment.NewLine, |
| 52 | + [ |
| 53 | + "# Commercial Evidence Dossier Intake Report", |
| 54 | + string.Empty, |
| 55 | + $"Run: `{Target.ExecutionRun.RunId}`", |
| 56 | + $"Intake: `{Target.IntakeId}`", |
| 57 | + $"Reviewer: `{Target.ReviewerName}`", |
| 58 | + $"Dossier root: `{Target.DossierRoot}`", |
| 59 | + $"Sources: `{SourceCount}`", |
| 60 | + $"Digests: `{DigestCount}`", |
| 61 | + $"Redaction reviews: `{RedactionReviewCount}`", |
| 62 | + $"Complete: `{Completeness.IsComplete}`", |
| 63 | + $"Blockers: `{Completeness.Blockers.Count}`" |
| 64 | + ]); |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +/// <summary> |
| 69 | +/// Provides commercial evidence dossier intake report helpers. |
| 70 | +/// </summary> |
| 71 | +public static class SigtranCommercialEvidenceDossierIntakeReports |
| 72 | +{ |
| 73 | + /// <summary>Creates the default retained dossier intake report.</summary> |
| 74 | + /// <param name="completeness">The artifact completeness result.</param> |
| 75 | + /// <returns>The dossier intake report.</returns> |
| 76 | + public static SigtranCommercialEvidenceDossierIntakeReport CreateDefault( |
| 77 | + SigtranCommercialEvidenceArtifactCompletenessResult completeness) |
| 78 | + { |
| 79 | + ArgumentNullException.ThrowIfNull(completeness); |
| 80 | + SigtranCommercialEvidenceArtifactIntakeTarget target = completeness.RedactionReviewManifest.DigestManifest.SourceManifest.Target; |
| 81 | + |
| 82 | + return new(completeness, $"{target.DossierRoot}/intake-report.md"); |
| 83 | + } |
| 84 | +} |
0 commit comments