Skip to content

Commit 79393af

Browse files
committed
[#68] Integrate Model Orphans Reporting
Trying to make it a bit more logical
1 parent 4c40df1 commit 79393af

File tree

4 files changed

+29
-35
lines changed

4 files changed

+29
-35
lines changed

src/LemonTree.Pipeline.Tools.ModelCheck/Checks/Checks.cs

+7-12
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ select count(t_object.Object_Type) as ['Count'], t_object.Object_Type as ['Measu
410410

411411
result.Level = IssueLevel.Information;
412412
result.Title = "Project Statistics";
413+
result.Detail = "Executed Project Statistics on Model";
413414

414415

415-
416-
result.Detail = ToMD(resultTable.DefaultView.ToTable(), header: true);
416+
result.Markdown = ToMD(resultTable.DefaultView.ToTable(), header: true);
417417

418418

419419
#endregion
@@ -431,11 +431,8 @@ internal static Issue CheckTableSize(string model)
431431
//resultTable.DefaultView.Sort = "table_size";
432432
resultTable.Columns[1].ColumnName = "table_size (bytes)";
433433

434-
Console.WriteLine(ToMD(resultTable, header: true));
435-
436434
#endregion
437435

438-
439436
#region process result table and calculate Issue number
440437

441438

@@ -447,10 +444,10 @@ internal static Issue CheckTableSize(string model)
447444

448445
result.Level = IssueLevel.Information;
449446
result.Title = "Table Statistics (all >32)";
447+
result.Detail = $"Found {resultTable.Rows.Count} Tables bigger 32";
450448

451449

452-
453-
result.Detail = ToMD(resultTable.DefaultView.ToTable(), header: true);
450+
result.Markdown = ToMD(resultTable.DefaultView.ToTable(), header: true);
454451

455452

456453
#endregion
@@ -482,11 +479,8 @@ AND t_object.ea_guid NOT IN (SELECT t_operation.Behaviour FROM t_operation WHERE
482479

483480
var resultTable = ModelAccess.RunSql(statisticSql);
484481

485-
Console.WriteLine(ToMD(resultTable, header: true));
486-
487482
#endregion
488483

489-
490484
#region process result table and calculate Issue number
491485

492486

@@ -497,12 +491,13 @@ AND t_object.ea_guid NOT IN (SELECT t_operation.Behaviour FROM t_operation WHERE
497491
Issue result = new Issue();
498492

499493
result.Level = IssueLevel.Information;
500-
result.Title = "Model Orphans Statistics (all >32)";
494+
result.Title = "Model Orphans Statistics";
501495

502496

503497
if (resultTable.Rows.Count > 0)
504498
{
505-
result.Detail = ToMD(resultTable.DefaultView.ToTable(), header: true);
499+
result.Markdown = ToMD(resultTable.DefaultView.ToTable(), header: true);
500+
result.Detail = $"Found {resultTable.Rows.Count} Orphans in Model";
506501
}
507502
else
508503
{

src/LemonTree.Pipeline.Tools.ModelCheck/Checks/Issue.cs

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ internal class Issue
66
internal string Detail { get; set; }
77
internal string Title { get; set; }
88

9+
internal string Markdown { get; set; }
10+
911
internal string Symbol
1012
{
1113
get

src/LemonTree.Pipeline.Tools.ModelCheck/Checks/Issues.cs

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ internal string ToMd()
1717
var mySortedList = this.OrderBy(x => x.Level);
1818
foreach (Issue issue in mySortedList)
1919
{
20-
21-
2220
sb.AppendLine($"|{issue.Symbol}|{issue.Level}|{issue.Title}|{issue.Detail}|");
2321
}
2422
return sb.ToString();

src/LemonTree.Pipeline.Tools.ModelCheck/Program.cs

+20-21
Original file line numberDiff line numberDiff line change
@@ -69,55 +69,54 @@ private static int RunModelCheck(ModelCheckOptions opts)
6969
issues.AddIfNotNull(Checks.Checks.CheckStrippedCompact(opts.Model));
7070
}
7171

72-
73-
// issues.WriteOutPut(Checks.Checks.CheckProjectStatitics(opts.Model));
74-
75-
76-
Console.WriteLine(issues.ToString());
77-
78-
StringBuilder sb = new StringBuilder();
79-
sb.AppendLine(issues.ToMd());
80-
sb.AppendLine("# Project Statistics");
81-
sb.AppendLine(Checks.Checks.CheckProjectStatitics(opts.Model).Detail);
82-
72+
Issue resultTableSize = null;
8373
if (opts.TableSize == true)
8474
{
8575
if (ModelAccess.IsSqlLite())
8676
{
87-
var result = Checks.Checks.CheckTableSize(opts.Model);
88-
sb.AppendLine(result.Detail);
89-
issues.AddIfNotNull(result);
77+
resultTableSize = Checks.Checks.CheckTableSize(opts.Model);
78+
79+
issues.AddIfNotNull(resultTableSize);
9080
}
9181
else
9282
{
9383
Console.WriteLine("Talbesize reporting only supported for SqlLite!");
9484
}
9585
}
9686

87+
Issue resultOrphans = null;
9788
if (opts.Orphans == true)
9889
{
9990
if (ModelAccess.IsSqlLite())
10091
{
101-
var result = Checks.Checks.CheckModelOrphans(opts.Model);
102-
sb.AppendLine(result.Detail);
103-
issues.AddIfNotNull(result);
92+
resultOrphans = Checks.Checks.CheckModelOrphans(opts.Model);
93+
issues.AddIfNotNull(resultOrphans);
10494
}
10595
else
10696
{
10797
Console.WriteLine("Orphans reporting only supported for SqlLite!");
10898
}
10999
}
110100

111-
112-
101+
Console.WriteLine(issues.ToString());
102+
StringBuilder sb = new StringBuilder();
103+
sb.AppendLine(issues.ToMd());
104+
sb.AppendLine("# Project Statistics");
105+
sb.AppendLine(Checks.Checks.CheckProjectStatitics(opts.Model).Markdown);
106+
if (resultTableSize != null)
107+
{
108+
sb.AppendLine(resultTableSize.Markdown);
109+
}
110+
if (resultOrphans != null)
111+
{
112+
sb.AppendLine(resultOrphans.Markdown);
113+
}
113114

114115
if (opts.Out != null)
115116
{
116117
File.WriteAllText(opts.Out, sb.ToString());
117118
}
118119

119-
120-
121120
if (opts.FailOnErrors == true)
122121
{
123122
if (issues.HasErrors())

0 commit comments

Comments
 (0)