Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to match users with different display name formats when migrating capacities #1985

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading