From 30641081a443da924f8840b50073c4f47b8f9939 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Sun, 31 Jul 2022 18:36:00 -0400 Subject: [PATCH] added printing to standard out functionality the author who has the highest commits in the repo, the commit count highlighted in yellow. the second highest commit count is highlighted grey, the third brown --- DAL/IDataService.cs | 4 ++++ DAL/StdOutDataService.cs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 DAL/IDataService.cs create mode 100644 DAL/StdOutDataService.cs diff --git a/DAL/IDataService.cs b/DAL/IDataService.cs new file mode 100644 index 0000000..4cf4d9c --- /dev/null +++ b/DAL/IDataService.cs @@ -0,0 +1,4 @@ +public interface IDataService +{ + void WriteAll(SortedList dictResults); +} diff --git a/DAL/StdOutDataService.cs b/DAL/StdOutDataService.cs new file mode 100644 index 0000000..e8e4ceb --- /dev/null +++ b/DAL/StdOutDataService.cs @@ -0,0 +1,30 @@ +using Pastel; + +public class StdOutDataService : IDataService +{ + public StdOutDataService() + { + + } + + public void WriteAll(SortedList dictResults) + { + ConsoleExtensions.Enable(); + // TODO: this is the ordered dictionary. replace the sorted list with this variable. + var sortedResults = dictResults.OrderByDescending(d => d.Value).ToList(); + System.Console.WriteLine("--- Commit Report ---"); + + foreach (var i in sortedResults) + { + if (i.Value == sortedResults[0].Value) { + Console.WriteLine($"Author: {i.Key}, Commits: {i.Value.ToString().Pastel("ffd700")}"); + } else if (i.Value == sortedResults[1].Value) { + Console.WriteLine($"Author: {i.Key}, Commits: {i.Value.ToString().Pastel("c0c0c0")}"); + } else if (i.Value == sortedResults[2].Value) { + Console.WriteLine($"Author: {i.Key}, Commits: {i.Value.ToString().Pastel("f4a460")}"); + } else { + Console.WriteLine($"Author: {i.Key}, Commits: {i.Value}"); + } + } + } +}