Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into fix/api/unhandled-api-exceptions
  • Loading branch information
BouVid committed Sep 26, 2023
2 parents e6d2358 + 972bbe2 commit 0459ec3
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public GetPersonProfiles(IEnumerable<Guid> azureObjectIds)
.ToList();
}

public List<PersonIdentifier> Identifiers { get; }
public List<PersonIdentifier> Identifiers { get; }

public class Handler : IRequestHandler<GetPersonProfiles, Dictionary<Guid, FusionPersonProfile>>
{
Expand All @@ -29,9 +29,20 @@ public Handler(IFusionProfileResolver profileResolver)
{
this.profileResolver = profileResolver;
}
public async Task<Dictionary<Guid,FusionPersonProfile>> Handle(GetPersonProfiles request, CancellationToken cancellationToken)
public async Task<Dictionary<Guid, FusionPersonProfile>> Handle(GetPersonProfiles request, CancellationToken cancellationToken)
{
var profiles = await profileResolver.ResolvePersonsAsync(request.Identifiers);
var tasks = new List<Task<IEnumerable<ResolvedPersonProfile>>>();

// Max number of identifiers is 500, so we chunk the requests
foreach (var req in request.Identifiers.Chunk(500))
{
tasks.Add(profileResolver.ResolvePersonsAsync(request.Identifiers));
}

var results = await Task.WhenAll(tasks);

var profiles = results.Select(p => p).SelectMany(p => p);

return profiles
.Where(p => p.Success && p.Profile?.AzureUniqueId != null)
.ToDictionary(
Expand Down

0 comments on commit 0459ec3

Please sign in to comment.