Skip to content

Commit

Permalink
Try to match users with different display name formats when migrating…
Browse files Browse the repository at this point in the history
… capacities
  • Loading branch information
tzavalunovaG committed Mar 18, 2024
1 parent bfc89d1 commit 7963f29
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,41 @@ private void MigrateCapacities(WorkHttpClient sourceHttpClient, WorkHttpClient t
sourceDisplayName = sourceDisplayName.Substring(0, index).Trim();
}

// Match:
// "Doe, John" to "Doe, John"
// "John Doe" to "John Doe"
var targetTeamFoundatationIdentity = _targetTeamFoundationIdentitiesLazyCache.Value.FirstOrDefault(i => i.DisplayName == sourceDisplayName);
if (targetTeamFoundatationIdentity == null)
{
if (sourceDisplayName.Contains(", "))
{
// Match:
// "Doe, John" to "John Doe"
var splitName = sourceDisplayName.Split(',');
sourceDisplayName = $"{splitName[1].Trim()} {splitName[0].Trim()}";
targetTeamFoundatationIdentity = _targetTeamFoundationIdentitiesLazyCache.Value.FirstOrDefault(i => i.DisplayName == sourceDisplayName);
}
else
{
if (sourceDisplayName.Contains(' '))
{
// Match:
// "John Doe" to "Doe, John"
var splitName = sourceDisplayName.Split(' ');
sourceDisplayName = $"{splitName[1].Trim()}, {splitName[0].Trim()}";
targetTeamFoundatationIdentity = _targetTeamFoundationIdentitiesLazyCache.Value.FirstOrDefault(i => i.DisplayName == sourceDisplayName);
}
}

// last attempt to match on unique name
// Match: "John Michael Bolden" to Bolden, "John Michael" on "john.m.bolden@example.com" unique name
if (targetTeamFoundatationIdentity == null)
{
var sourceUniqueName = sourceCapacity.TeamMember.UniqueName;
targetTeamFoundatationIdentity = _targetTeamFoundationIdentitiesLazyCache.Value.FirstOrDefault(i => i.UniqueName == sourceUniqueName);
}
}

if (targetTeamFoundatationIdentity != null)
{
targetCapacities.Add(new TeamMemberCapacityIdentityRef
Expand Down

0 comments on commit 7963f29

Please sign in to comment.