data integrity report working

This commit is contained in:
Shannon
2020-04-08 10:38:02 +10:00
parent 19f0793cba
commit 49c6fd2c76
3 changed files with 19 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
namespace Umbraco.Core.Models
{
@@ -9,7 +10,7 @@ namespace Umbraco.Core.Models
DetectedIssues = detectedIssues;
}
public bool Ok => DetectedIssues.Count == 0;
public bool Ok => DetectedIssues.Count == 0 || DetectedIssues.Count == DetectedIssues.Values.Count(x => x.Fixed);
public IReadOnlyDictionary<int, ContentDataIntegrityReportEntry> DetectedIssues { get; }

View File

@@ -578,6 +578,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
foreach (var node in updated)
{
Database.Update(node);
if (report.TryGetValue(node.NodeId, out var entry))
entry.Fixed = true;
}
}

View File

@@ -68,21 +68,30 @@ namespace Umbraco.Web.HealthCheck.Checks.Data
});
}
return new HealthCheckStatus(report.Ok
? $"All {entityType} paths are valid"
: GetInvalidReport(report, entityType, detailedReport))
return new HealthCheckStatus(GetReport(report, entityType, detailedReport))
{
ResultType = report.Ok ? StatusResultType.Success : StatusResultType.Error,
Actions = actions
};
}
private static string GetInvalidReport(ContentDataIntegrityReport report, string entityType, bool detailed)
private static string GetReport(ContentDataIntegrityReport report, string entityType, bool detailed)
{
var sb = new StringBuilder();
sb.AppendLine($"There are {report.DetectedIssues.Count} invalid {entityType} paths");
if (true && report.DetectedIssues.Count > 0)
if (report.Ok)
{
sb.AppendLine($"<p>All {entityType} paths are valid</p>");
if (!detailed)
return sb.ToString();
}
else
{
sb.AppendLine($"<p>{report.DetectedIssues.Count} invalid {entityType} paths detected.</p>");
}
if (detailed && report.DetectedIssues.Count > 0)
{
sb.AppendLine("<ul>");
foreach (var issueGroup in report.DetectedIssues.GroupBy(x => x.Value.IssueType))