You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request refactors the `TfsWorkItemMigrationProcessor` class by
removing unused code, improving validation logic, and enhancing logging
and telemetry. The changes aim to simplify the codebase, improve
maintainability, and provide better insights during execution. Below are
the most important changes grouped by theme:
### Code Simplification and Cleanup:
* Removed the `ProgressTimer` class and associated logic, replacing it
with simpler calculations for average and remaining time during work
item processing.
(`src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessor.cs`)
[[1]](diffhunk://#diff-b0a23408b76051c7078de3664c94b03ef26ca367ede9f084067d8722393f130eL40-L70)
[[2]](diffhunk://#diff-b0a23408b76051c7078de3664c94b03ef26ca367ede9f084067d8722393f130eL181)
[[3]](diffhunk://#diff-b0a23408b76051c7078de3664c94b03ef26ca367ede9f084067d8722393f130eL643-R689)
* Removed unused imports from `TfsValidateRequiredFieldTool.cs` to clean
up dependencies.
(`src/MigrationTools.Clients.TfsObjectModel/Tools/TfsValidateRequiredFieldTool.cs`)
### Validation Improvements:
* Enhanced the `ValiddateWorkItemTypesExistInTarget` method to include
detailed logging for missing work item types, suggestions for mapping
based on character similarity, and explicit error messages for unmapped
types.
(`src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessor.cs`)
* Fixed a typo in the method name `ValiddateWorkItemTypesExistInTarget`
to maintain consistency.
(`src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessor.cs`)
### Logging and Telemetry Enhancements:
* Improved exception logging in `ValidatingRequiredField` to include the
work item type name for better debugging.
(`src/MigrationTools.Clients.TfsObjectModel/Tools/TfsValidateRequiredFieldTool.cs`)
* Added telemetry tags and end time tracking to activities in
`ProcessWorkItemAsync` for better observability.
(`src/MigrationTools.Clients.TfsObjectModel/Processors/TfsWorkItemMigrationProcessor.cs`)
[[1]](diffhunk://#diff-b0a23408b76051c7078de3664c94b03ef26ca367ede9f084067d8722393f130eR404)
[[2]](diffhunk://#diff-b0a23408b76051c7078de3664c94b03ef26ca367ede9f084067d8722393f130eL533-R577)
### Configuration Update:
* Updated the `launchSettings.json` file to use a specific configuration
file path for execution, likely for testing or debugging purposes.
(`src/MigrationTools.ConsoleFull/Properties/launchSettings.json`)
Log.LogDebug("Validating::WorkItemTypes::sourceWorkItemTypes: {count} WorkItemTypes in the full source history {sourceWorkItemTypesString}",sourceWorkItemTypes.Count(),string.Join(",",sourceWorkItemTypes));
270
+
varsourceWorkItemTypes=sourceWorkItems
271
+
.SelectMany(x =>x.Revisions.Values)
272
+
.Select(x =>x.Type)
273
+
.Distinct()
274
+
.ToList();
275
+
276
+
Log.LogDebug("Validating::WorkItemTypes::sourceWorkItemTypes: {count} WorkItemTypes in the full source history: {sourceWorkItemTypesString}",
varmissingWorkItemTypes=sourceWorkItemTypes.Where(sourceWit =>!targetWorkItemTypes.Contains(sourceWit));// the real one
313
-
if(missingWorkItemTypes.Count()>0)
308
+
if(missingWorkItemTypes.Count>0)
314
309
{
315
-
Log.LogWarning("Validating::WorkItemTypes::targetWorkItemTypes::There are {count} WorkItemTypes that are used in the history of the Source and that do not exist in the Target. These will all need mapped using `WorkItemTypeDefinition` in the config. ",missingWorkItemTypes.Count());
310
+
Log.LogWarning("There are {count} WorkItemTypes used in source history that do not exist in the target. These may need to be mapped.",missingWorkItemTypes.Count);
"Processed {processedItemsCount} items from {totalItemsCount} with average process time {average:%s}.{average:%fff} s (total processing time is {totalProcessedTime:h\\:mm\\:ss}). "
647
-
+"Estimated time to completion is {remaining:%h} hours {remaining:%m} minutes {remaining:%s} seconds.",
684
+
"Average time of {average:%s}.{average:%fff} per work item and {remaining:%h} hours {remaining:%m} minutes {remaining:%s}.{remaining:%fff} seconds estimated to completion",
@@ -265,7 +261,8 @@ private WorkItem GetDummyWorkItem(WorkItemType type = null)
265
261
if(_targetDummyWorkItem.Id==0)
266
262
{
267
263
thrownewException("The Dummy work Item cant be created due to a save failure. This is likley due to required fields on the Task or First work items type.");
268
-
}else
264
+
}
265
+
else
269
266
{
270
267
Log.LogDebug("TfsEmbededImagesTool: Dummy workitem {id} created on the target collection.",_targetDummyWorkItem.Id);
@@ -56,7 +53,7 @@ public bool ValidatingRequiredField(TfsProcessor processor, string fieldToFind,
56
53
}
57
54
catch(WorkItemTypeDeniedOrNotExistExceptionex)
58
55
{
59
-
Log.LogWarning(ex,"ValidatingRequiredField: Unable to validate one of the work items as its returned by TFS but has been deleted");
56
+
Log.LogWarning(ex,"ValidatingRequiredField: Unable to validate work item type {name} as its returned by the source but does not exist in the target",sourceWorkItemType.Name);
60
57
}
61
58
62
59
}
@@ -81,4 +78,4 @@ public bool ValidatingRequiredField(TfsProcessor processor, string fieldToFind,
0 commit comments