From 467135e41f47328d72bfa3e4129d77145e2d7770 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 24 Feb 2021 23:09:55 -0500 Subject: [PATCH] fix saturation calculation --- src/BirdsiteLive/Services/CachedStatisticsService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/BirdsiteLive/Services/CachedStatisticsService.cs b/src/BirdsiteLive/Services/CachedStatisticsService.cs index e32e0f8..9337797 100644 --- a/src/BirdsiteLive/Services/CachedStatisticsService.cs +++ b/src/BirdsiteLive/Services/CachedStatisticsService.cs @@ -1,7 +1,7 @@ using System; using System.Threading.Tasks; +using BirdsiteLive.Common.Settings; using BirdsiteLive.DAL.Contracts; -using BirdsiteLive.Statistics.Domain; namespace BirdsiteLive.Services { @@ -12,16 +12,16 @@ namespace BirdsiteLive.Services public class CachedStatisticsService : ICachedStatisticsService { - private readonly ITwitterStatisticsHandler _twitterStatisticsHandler; private readonly ITwitterUserDal _twitterUserDal; private static CachedStatistics _cachedStatistics; + private readonly InstanceSettings _instanceSettings; #region Ctor - public CachedStatisticsService(ITwitterStatisticsHandler twitterStatisticsHandler, ITwitterUserDal twitterUserDal) + public CachedStatisticsService(ITwitterUserDal twitterUserDal, InstanceSettings instanceSettings) { - _twitterStatisticsHandler = twitterStatisticsHandler; _twitterUserDal = twitterUserDal; + _instanceSettings = instanceSettings; } #endregion @@ -30,7 +30,7 @@ namespace BirdsiteLive.Services if (_cachedStatistics == null || (DateTime.UtcNow - _cachedStatistics.RefreshedTime).TotalMinutes > 15) { - var twitterUserMax = _twitterStatisticsHandler.GetStatistics().UserCallsMax; + var twitterUserMax = _instanceSettings.MaxUsersCapacity; var twitterUserCount = await _twitterUserDal.GetTwitterUsersCountAsync(); var saturation = (int)((double)twitterUserCount / twitterUserMax * 100);