moved followers retrieval

This commit is contained in:
Vincent Cloutier 2023-03-25 13:24:11 -04:00
parent 62caf7e956
commit 8d6851c639
3 changed files with 18 additions and 13 deletions

View File

@ -21,18 +21,18 @@ namespace BirdsiteLive.Pipeline.Processors
public async Task<IEnumerable<UserWithDataToSync>> ProcessAsync(UserWithDataToSync[] userWithTweetsToSyncs, CancellationToken ct)
{
List<Task> todo = new List<Task>();
foreach (var user in userWithTweetsToSyncs)
{
var t = Task.Run(
async() => {
var followers = await _followersDal.GetFollowersAsync(user.User.Id);
user.Followers = followers;
});
todo.Add(t);
}
await Task.WhenAll(todo);
//List<Task> todo = new List<Task>();
//foreach (var user in userWithTweetsToSyncs)
//{
// 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;
}

View File

@ -49,6 +49,10 @@ namespace BirdsiteLive.Pipeline.Processors
var t = Task.Run( async () =>
{
if (userWithTweetsToSync.Followers is null || userWithTweetsToSync.Followers.Length == 0)
{
userWithTweetsToSync.Followers = await _followersDal.GetFollowersAsync(user.Id);
}
// Process Shared Inbox
var followersWtSharedInbox = userWithTweetsToSync.Followers
.Where(x => !string.IsNullOrWhiteSpace(x.SharedInboxRoute))
@ -60,7 +64,7 @@ namespace BirdsiteLive.Pipeline.Processors
.Where(x => string.IsNullOrWhiteSpace(x.SharedInboxRoute))
.ToList();
await ProcessFollowersWithInboxAsync(userWithTweetsToSync.Tweets, followerWtInbox, user);
});
}, ct);
_todo.Add(t);
if (_todo.Count >= _instanceSettings.ParallelFediversePosts)

View File

@ -14,6 +14,7 @@ namespace BirdsiteLive.Pipeline.Tests.Processors
[TestClass]
public class RetrieveFollowersProcessorTests
{
[Ignore]
[TestMethod]
public async Task ProcessAsync_Test()
{