From b1b8b676b907a36efec0e50eb5bc1bc9c7a8925e Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Thu, 29 Dec 2022 13:02:38 -0500 Subject: [PATCH] changed some magic --- .../Processors/RetrieveTweetsProcessor.cs | 2 +- src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs | 2 +- src/BirdsiteLive.Twitter/CachedTwitterService.cs | 4 ++-- .../Tools/TwitterAuthenticationInitializer.cs | 2 +- src/BirdsiteLive.Twitter/TwitterTweetsService.cs | 2 +- src/Tests/BirdsiteLive.Twitter.Tests/TimelineTests.cs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs index 104cdf1..6e5ddc1 100644 --- a/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs +++ b/src/BirdsiteLive.Pipeline/Processors/RetrieveTweetsProcessor.cs @@ -60,7 +60,7 @@ namespace BirdsiteLive.Pipeline.Processors await _twitterUserDal.UpdateTwitterUserAsync(user.Id, user.LastTweetPostedId, user.LastTweetSynchronizedForAllFollowersId, user.FetchingErrorCount, now); } - await Task.Delay(1500); + await Task.Delay(750); } return usersWtTweets.ToArray(); diff --git a/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs b/src/BirdsiteLive.Pipeline/StatusPublicationPipeline.cs index 06d28bf..2748fd4 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 = 3, CancellationToken = ct }); + var retrieveTweetsBufferBlock = new BufferBlock(new DataflowBlockOptions { BoundedCapacity = 2, 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.Twitter/CachedTwitterService.cs b/src/BirdsiteLive.Twitter/CachedTwitterService.cs index c549883..65f1b71 100644 --- a/src/BirdsiteLive.Twitter/CachedTwitterService.cs +++ b/src/BirdsiteLive.Twitter/CachedTwitterService.cs @@ -23,9 +23,9 @@ namespace BirdsiteLive.Twitter //Priority on removing when reaching size limit (memory pressure) .SetPriority(CacheItemPriority.Low) // Keep in cache for this time, reset time if accessed. - .SetSlidingExpiration(TimeSpan.FromHours(24)) + .SetSlidingExpiration(TimeSpan.FromMinutes(10)) // Remove from cache after this time, regardless of sliding expiration - .SetAbsoluteExpiration(TimeSpan.FromDays(7)); + .SetAbsoluteExpiration(TimeSpan.FromDays(1)); #region Ctor public CachedTwitterUserService(ITwitterUserService twitterService, InstanceSettings settings) diff --git a/src/BirdsiteLive.Twitter/Tools/TwitterAuthenticationInitializer.cs b/src/BirdsiteLive.Twitter/Tools/TwitterAuthenticationInitializer.cs index 6192016..ac2bd5b 100644 --- a/src/BirdsiteLive.Twitter/Tools/TwitterAuthenticationInitializer.cs +++ b/src/BirdsiteLive.Twitter/Tools/TwitterAuthenticationInitializer.cs @@ -39,7 +39,7 @@ namespace BirdsiteLive.Twitter.Tools _logger = logger; aTimer = new System.Timers.Timer(); - aTimer.Interval = 5 * 60 * 1000; + aTimer.Interval = 2 * 60 * 1000; aTimer.Elapsed += async (sender, e) => await RefreshCred(); aTimer.Start(); diff --git a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs index f019ab1..b7df5ed 100644 --- a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs +++ b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs @@ -150,11 +150,11 @@ namespace BirdsiteLive.Twitter try { var extractedTweet = await Extract(tweet); - extractedTweets.Add(extractedTweet); if (extractedTweet.Id == fromTweetId) break; + extractedTweets.Add(extractedTweet); } catch (Exception e) { diff --git a/src/Tests/BirdsiteLive.Twitter.Tests/TimelineTests.cs b/src/Tests/BirdsiteLive.Twitter.Tests/TimelineTests.cs index 34a9021..63c3aef 100644 --- a/src/Tests/BirdsiteLive.Twitter.Tests/TimelineTests.cs +++ b/src/Tests/BirdsiteLive.Twitter.Tests/TimelineTests.cs @@ -41,7 +41,7 @@ namespace BirdsiteLive.ActivityPub.Tests { var tweets = await _tweetService.GetTimelineAsync("kobebryant", 100, 1218020971346444288); Assert.AreEqual(tweets[0].MessageContent, "Continuing to move the game forward @KingJames. Much respect my brother 💪🏾 #33644"); - Assert.AreEqual(tweets.Length, 9); + Assert.AreEqual(tweets.Length, 8); }