Skip to content

Commit

Permalink
support exporting Outstanding Failures to file
Browse files Browse the repository at this point in the history
  • Loading branch information
rkm committed Dec 7, 2023
1 parent 96f4261 commit 6db3433
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 21 additions & 1 deletion ii/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using IsIdentifiable.Rules;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -86,7 +87,8 @@ public MainWindow(IsIdentifiableOptions analyserOpts, IsIdentifiableReviewerOpti
Menu = new MenuBar(new MenuBarItem[] {
new("_File (F9)", new MenuItem [] {
new("_Open Report",null, OpenReport),
new("_Quit", null, static () => Application.RequestStop())
new("_Export 'Outstanding Failures'", null, ExportOutstandingFailures),
new("_Quit", null, static () => Application.RequestStop()),
}),
new("_Options", new MenuItem [] {
miCustomPatterns = new MenuItem("_Custom Patterns",null,ToggleCustomPatterns){CheckType = MenuItemCheckStyle.Checked,Checked = false}
Expand Down Expand Up @@ -431,6 +433,24 @@ private void Update()
BeginNext();
}

private void ExportOutstandingFailures()
{
if (rulesView.OutstandingFiles == null)
{
Helpers.ShowMessage("Error", "You must evaluate the rules on a report first.");
return;
}

var now = DateTime.UtcNow.ToString("s").Replace(':', '-');
var fileName = $"OutstandingFiles-{now}.csv";
using var sw = new StreamWriter(fileName);

foreach (var file in rulesView.OutstandingFiles)
sw.WriteLine(file);

Helpers.ShowMessage("Complete", $"Wrote {rulesView.OutstandingFiles.Count} unique item(s) to {fileName}");
}

private void OpenReport()
{
using var ofd = new OpenDialog("Load CSV Report", "Enter file path to load")
Expand Down
4 changes: 4 additions & 0 deletions ii/Views/RulesView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class RulesView : View
public IgnoreRuleGenerator? Ignorer { get; private set; }
public RowUpdater? Updater { get; private set; }

public List<string>? OutstandingFiles { get; private set; }

private readonly TreeView _treeView;

/// <summary>
Expand Down Expand Up @@ -536,6 +538,8 @@ private void EvaluateRuleCoverageAsync(Label stage, ProgressBar progress, Label
.OrderByDescending(v => v.Failures.Sum(f => f.NumberOfTimesReported))
.Cast<ITreeNode>()
.ToList();

OutstandingFiles = outstandingFailures.Select(x => x.Value.Failure.Resource).Distinct().ToList();
}

private static void SetProgress(ProgressBar pb, View tp, int done, int max)
Expand Down

0 comments on commit 6db3433

Please sign in to comment.