Tag property on Record

Fetch javascript function for testing

Absolute Delta
This commit is contained in:
Mike Phares 2025-04-17 16:19:14 -07:00
parent 3e8f5931e2
commit 9c5e6fddf2
9 changed files with 162 additions and 16629 deletions

View File

@ -5,6 +5,12 @@
"type": "coreclr",
"request": "attach",
"processId": 22868
},
{
"type": "node",
"request": "launch",
"name": "node Launch Current Opened File",
"program": "${file}"
}
]
}

View File

@ -151,7 +151,8 @@ public class ProcessData : IProcessData
}
catch (Exception)
{
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
Dictionary<string, string>? tag = null;
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>(), tag);
}
results.Add(keyValuePair.Key, record);
}

View File

@ -169,7 +169,8 @@ public class ProcessData : IProcessData
}
catch (Exception)
{
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
Dictionary<string, string>? tag = null;
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>(), tag);
}
results.Add(keyValuePair.Key, record);
}

View File

@ -145,7 +145,8 @@ public class ProcessData : IProcessData
}
catch (Exception)
{
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
Dictionary<string, string>? tag = null;
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>(), tag);
}
results.Add(keyValuePair.Key, record);
}
@ -174,7 +175,7 @@ public class ProcessData : IProcessData
{
if (r.WorkItem.State == "Removed" || !workItemTypes.Contains(r.WorkItem.WorkItemType))
continue;
record = new(r.WorkItem, r.Parent, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
record = new(r.WorkItem, r.Parent, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>(), r.Tag);
filtered.Add(record);
}
string? json = GetJson(filtered, results);

View File

@ -155,7 +155,7 @@ public class FileRead : Shared.FileRead, IFileRead
matchDirectoryFileName = Path.GetFileName(matchDirectoryFile);
if (jobIdDirectoryFileName.StartsWith(matchDirectoryFileName))
{
checkFile = Path.Combine(matchDirectory, Path.GetFileName(matchDirectoryFile));
checkFile = Path.Combine(matchDirectory, jobIdDirectoryFileName);
if (File.Exists(checkFile))
continue;
File.Move(jobIdDirectoryFile, checkFile);

View File

@ -173,7 +173,8 @@ public class ProcessData : IProcessData
}
catch (Exception)
{
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
Dictionary<string, string>? tag = null;
record = new(keyValuePair.Value, parentWorkItem, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>(), tag);
}
results.Add(keyValuePair.Key, record);
}

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Adaptation.FileHandlers.json.WorkItems;
@ -12,13 +13,14 @@ internal class Record
#nullable enable
[JsonConstructor]
public Record(WorkItem workItem, WorkItem? parent, Record[]? children, Record[]? related, Record[]? successors)
public Record(WorkItem workItem, WorkItem? parent, Record[]? children, Record[]? related, Record[]? successors, Dictionary<string, string>? tag)
{
WorkItem = workItem;
Parent = parent;
Children = children;
Related = related;
Successors = successors;
Tag = tag;
}
[JsonPropertyName("WorkItem")] public WorkItem WorkItem { get; set; }
@ -26,6 +28,7 @@ internal class Record
[JsonPropertyName("Children")] public Record[]? Children { get; set; }
[JsonPropertyName("Related")] public Record[]? Related { get; set; }
[JsonPropertyName("Successors")] public Record[]? Successors { get; set; }
[JsonPropertyName("Tag")] public Dictionary<string, string>? Tag { get; set; }
internal static Record GetWithoutNesting(Record record, string? violation)
{
@ -60,7 +63,7 @@ internal class Record
violation: record.WorkItem.Violation is null ? violation : record.WorkItem.Violation,
weightedShortestJobFirst: record.WorkItem.WeightedShortestJobFirst,
workItemType: record.WorkItem.WorkItemType);
result = new(workItem, record.Parent, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>());
result = new(workItem, record.Parent, Array.Empty<Record>(), Array.Empty<Record>(), Array.Empty<Record>(), record.Tag);
return result;
}
@ -100,14 +103,40 @@ internal class Record
relationRecords.Add(Get(r, keepRelations));
successorRecords = relationRecords.ToArray();
}
result = new(workItem, parentWorkItem, childRecords, relatedRecords, successorRecords);
result = new(workItem, parentWorkItem, childRecords, relatedRecords, successorRecords, record.Tag);
return result;
}
internal static Dictionary<string, string>? GetTag(ReadOnlyCollection<Record>? records)
{
Dictionary<string, string>? result;
if (records is null)
result = null;
else
{
List<long> collection = new();
foreach (Record record in records)
{
if (record.WorkItem.State is "Closed" or "Resolved" || record.WorkItem.StoryPoints is null)
continue;
collection.Add(record.WorkItem.StoryPoints.Value);
}
if (collection.Count == 0)
result = null;
else
{
string json = JsonSerializer.Serialize(collection);
result = new Dictionary<string, string> { { "StoryPoints", json } };
}
}
return result;
}
internal static Record Get(WorkItem workItem, WorkItem? parent, ReadOnlyCollection<Record>? children, ReadOnlyCollection<Record>? related, ReadOnlyCollection<Record>? successors, bool keepRelations)
{
Record result;
Record record = new(workItem, parent, children?.ToArray(), related?.ToArray(), successors?.ToArray());
Dictionary<string, string>? tag = GetTag(children);
Record record = new(workItem, parent, children?.ToArray(), related?.ToArray(), successors?.ToArray(), tag);
result = Get(record, keepRelations);
return result;
}

View File

@ -192,7 +192,7 @@ public class MESAFIBACKLOG
NonThrowTryCatch();
}
#if DEBUG
#if (!DEBUG)
[Ignore]
#endif
[TestMethod]