From 66e1e84da24843181d946465e489d85e0f06d15c Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Sun, 5 Sep 2021 01:03:01 -0400 Subject: [PATCH] added waiting time to fit 100.000 rate limit --- .../Processors/RetrieveTwitterUsersProcessor.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/BirdsiteLive.Pipeline/Processors/RetrieveTwitterUsersProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/RetrieveTwitterUsersProcessor.cs index ebb87fc..4e6b693 100644 --- a/src/BirdsiteLive.Pipeline/Processors/RetrieveTwitterUsersProcessor.cs +++ b/src/BirdsiteLive.Pipeline/Processors/RetrieveTwitterUsersProcessor.cs @@ -55,7 +55,12 @@ namespace BirdsiteLive.Pipeline.Processors } var splitCount = splitUsers.Count(); - if (splitCount < 15) await Task.Delay((15 - splitCount) * WaitFactor, ct); + if (splitCount < 15) await Task.Delay((15 - splitCount) * WaitFactor, ct); //Always wait 15min + + // Extra wait time to fit 100.000/day limit + var extraWaitTime = (int)Math.Ceiling((60 / ((100000d / 24) / userCount)) - 15); + if (extraWaitTime < 0) extraWaitTime = 0; + await Task.Delay(extraWaitTime * 1000, ct); } catch (Exception e) {