made RetrieveFollowersProcessor more parallel

This commit is contained in:
Vincent Cloutier 2022-12-28 10:59:15 -05:00
parent dc34228659
commit 6b6a943294

View file

@ -20,12 +20,17 @@ namespace BirdsiteLive.Pipeline.Processors
public async Task<IEnumerable<UserWithDataToSync>> ProcessAsync(UserWithDataToSync[] userWithTweetsToSyncs, CancellationToken ct)
{
//TODO multithread this
List<Task> todo = new List<Task>();
foreach (var user in userWithTweetsToSyncs)
{
var followers = await _followersDal.GetFollowersAsync(user.User.Id);
user.Followers = followers;
var t = Task.Run(
async() => {
var followers = await _followersDal.GetFollowersAsync(user.User.Id);
user.Followers = followers;
});
todo.Add(t);
}
await Task.WhenAll(todo);
return userWithTweetsToSyncs;
}