From 94f8d4025665d35af67c09414522252343d55bbf Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Mon, 26 Dec 2022 11:48:13 -0500 Subject: [PATCH] more tweaks --- .../Processors/RetrieveTweetsProcessor.cs | 2 +- .../Processors/RetrieveTwitterUsersProcessor.cs | 2 +- src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs | 2 +- src/BirdsiteLive/Controllers/UsersController.cs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs index 4d76f3b..69a48a4 100644 --- a/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs +++ b/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs @@ -58,7 +58,7 @@ namespace BirdsiteLive.Pipeline.Processors await _twitterUserDal.UpdateTwitterUserAsync(user.Id, user.LastTweetPostedId, user.LastTweetSynchronizedForAllFollowersId, user.FetchingErrorCount, now); } - await Task.Delay(4 * 1000); + await Task.Delay(1 * 1000); } return usersWtTweets.ToArray(); diff --git a/src/BirdsiteLive.Pipeline/Processors/RetrieveTwitterUsersProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/RetrieveTwitterUsersProcessor.cs index 0b03f62..7e6ef8e 100644 --- a/src/BirdsiteLive.Pipeline/Processors/RetrieveTwitterUsersProcessor.cs +++ b/src/BirdsiteLive.Pipeline/Processors/RetrieveTwitterUsersProcessor.cs @@ -54,7 +54,7 @@ namespace BirdsiteLive.Pipeline.Processors await twitterUsersBufferBlock.SendAsync(u.ToArray(), ct); } - await Task.Delay(1000, ct); + //await Task.Delay(1000, ct); } catch (Exception e) { diff --git a/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs b/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs index c6917e7..4fda09f 100644 --- a/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs +++ b/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs @@ -47,7 +47,7 @@ namespace BirdsiteLive.Pipeline var twitterUserToRefreshBlock = new TransformBlock(async x => await _refreshTwitterUserStatusProcessor.ProcessAsync(x, ct)); var twitterUsersBufferBlock = new BufferBlock(new DataflowBlockOptions { BoundedCapacity = 1, CancellationToken = ct }); var retrieveTweetsBlock = new TransformBlock(async x => await _retrieveTweetsProcessor.ProcessAsync(x, ct)); - var retrieveTweetsBufferBlock = new BufferBlock(new DataflowBlockOptions { BoundedCapacity = 1, CancellationToken = ct }); + var retrieveTweetsBufferBlock = new BufferBlock(new DataflowBlockOptions { BoundedCapacity = 5, CancellationToken = ct }); var retrieveFollowersBlock = new TransformManyBlock(async x => await _retrieveFollowersProcessor.ProcessAsync(x, ct)); var retrieveFollowersBufferBlock = new BufferBlock(new DataflowBlockOptions { BoundedCapacity = 20, CancellationToken = ct }); var sendTweetsToFollowersBlock = new TransformBlock(async x => await _sendTweetsToFollowersProcessor.ProcessAsync(x, ct), new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 5, CancellationToken = ct }); diff --git a/src/BirdsiteLive/Controllers/UsersController.cs b/src/BirdsiteLive/Controllers/UsersController.cs index f5e584e..73207ea 100644 --- a/src/BirdsiteLive/Controllers/UsersController.cs +++ b/src/BirdsiteLive/Controllers/UsersController.cs @@ -135,7 +135,7 @@ namespace BirdsiteLive.Controllers [Route("/@{id}/{statusId}")] [Route("/users/{id}/statuses/{statusId}")] - public IActionResult Tweet(string id, string statusId) + public async Task Tweet(string id, string statusId) { var acceptHeaders = Request.Headers["Accept"]; if (acceptHeaders.Any()) @@ -146,7 +146,7 @@ namespace BirdsiteLive.Controllers if (!long.TryParse(statusId, out var parsedStatusId)) return NotFound(); - var tweet = _twitterTweetService.GetTweet(parsedStatusId); + var tweet = await _twitterTweetService.GetTweetAsync(parsedStatusId); if (tweet == null) return NotFound();