From 65e31b09cc5ec372eafc4906af687f24fa696243 Mon Sep 17 00:00:00 2001 From: Mike Phares Date: Mon, 16 Sep 2024 10:43:51 -0700 Subject: [PATCH] Iteration Path --- Adaptation/FileHandlers/json/FileRead.cs | 27 +++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Adaptation/FileHandlers/json/FileRead.cs b/Adaptation/FileHandlers/json/FileRead.cs index ddc05d9..52951df 100644 --- a/Adaptation/FileHandlers/json/FileRead.cs +++ b/Adaptation/FileHandlers/json/FileRead.cs @@ -271,19 +271,20 @@ public class FileRead : Shared.FileRead, IFileRead return result; } - private static string GetLine(List spaces, WorkItem workItem, KeyValuePair keyValuePair, bool condensed) => - !condensed ? $"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title}" : - $"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title} ~~~ {workItem.AssignedTo} - {workItem.IterationPath.Replace('\\', '-')} - {workItem.CreatedDate} --- {workItem.ClosedDate}"; + private static string GetLine(List spaces, WorkItem workItem, KeyValuePair keyValuePair, bool condensed, bool sprintOnly) => + sprintOnly ? $"\t- [ ] {workItem.IterationPath}" : + condensed ? $"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title}" : + $"{new string(spaces.Skip(1).ToArray())}- {GetClosed(workItem)} {keyValuePair.Key} - {workItem.Title} ~~~ {workItem.AssignedTo} - {workItem.IterationPath.Replace('\\', '-')} - {workItem.CreatedDate} --- {workItem.ClosedDate}"; - private static void AppendLines(List spaces, List lines, Record record, bool condensed) + private static void AppendLines(List spaces, List lines, Record record, bool condensed, bool sprintOnly) { spaces.Add('\t'); WorkItem workItem; foreach (KeyValuePair keyValuePair in record.Children) { workItem = keyValuePair.Value.WorkItem; - lines.Add(GetLine(spaces, workItem, keyValuePair, condensed)); - AppendLines(spaces, lines, keyValuePair.Value, condensed); + lines.Add(GetLine(spaces, workItem, keyValuePair, condensed, sprintOnly)); + AppendLines(spaces, lines, keyValuePair.Value, condensed, sprintOnly); } spaces.RemoveAt(0); } @@ -291,6 +292,7 @@ public class FileRead : Shared.FileRead, IFileRead private static void AppendLines(List spaces, List lines, ReadOnlyDictionary workItemAndChildren, string workItemType) { WorkItem workItem; + List distinct = new(); foreach (KeyValuePair keyValuePair in workItemAndChildren) { workItem = keyValuePair.Value.WorkItem; @@ -302,11 +304,20 @@ public class FileRead : Shared.FileRead, IFileRead lines.Add(string.Empty); if (keyValuePair.Value.Children.Count > 0) { - AppendLines(spaces, lines, keyValuePair.Value, condensed: true); + AppendLines(spaces, lines, keyValuePair.Value, condensed: true, sprintOnly: false); + lines.Add(string.Empty); + distinct.Clear(); + lines.Add($"## Distinct Iteration Path(s) - {workItem.WorkItemType} - {workItem.AssignedTo} - {workItem.Id} - {workItem.Title} - {workItem.IterationPath}"); + lines.Add(string.Empty); + lines.Add($"- [{workItem.Id}](https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/{workItem.Id})"); + lines.Add(string.Empty); + AppendLines(spaces, distinct, keyValuePair.Value, condensed: false, sprintOnly: true); + distinct.Sort(); + lines.AddRange(distinct.Distinct()); lines.Add(string.Empty); lines.Add($"## Extended - {workItem.Id} - {workItem.Title}"); lines.Add(string.Empty); - AppendLines(spaces, lines, keyValuePair.Value, condensed: false); + AppendLines(spaces, lines, keyValuePair.Value, condensed: false, sprintOnly: false); lines.Add(string.Empty); } }