retrieval of dynamic values
This commit is contained in:
parent
bf660b80f6
commit
45255fa39d
1 changed files with 19 additions and 9 deletions
|
@ -2,7 +2,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BirdsiteLive.DAL.Contracts;
|
||||
using BirdsiteLive.Domain.Repository;
|
||||
using BirdsiteLive.Statistics.Domain;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BirdsiteLive.Component
|
||||
|
@ -10,34 +12,42 @@ namespace BirdsiteLive.Component
|
|||
public class NodeInfoViewComponent : ViewComponent
|
||||
{
|
||||
private readonly IModerationRepository _moderationRepository;
|
||||
private readonly ITwitterStatisticsHandler _twitterStatisticsHandler;
|
||||
private readonly ITwitterUserDal _twitterUserDal;
|
||||
|
||||
#region Ctor
|
||||
public NodeInfoViewComponent(IModerationRepository moderationRepository)
|
||||
public NodeInfoViewComponent(IModerationRepository moderationRepository, ITwitterStatisticsHandler twitterStatisticsHandler, ITwitterUserDal twitterUserDal)
|
||||
{
|
||||
_moderationRepository = moderationRepository;
|
||||
_twitterStatisticsHandler = twitterStatisticsHandler;
|
||||
_twitterUserDal = twitterUserDal;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public IViewComponentResult Invoke()
|
||||
public async Task<IViewComponentResult> InvokeAsync()
|
||||
{
|
||||
var followerPolicy = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.Follower);
|
||||
var twitterAccountPolicy = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.TwitterAccount);
|
||||
|
||||
var twitterUserMax = _twitterStatisticsHandler.GetStatistics().UserCallsMax;
|
||||
var twitterUserCount = await _twitterUserDal.GetTwitterUsersCountAsync();
|
||||
var saturation = (int)((double)twitterUserCount / twitterUserMax * 100);
|
||||
|
||||
var viewModel = new NodeInfoViewModel
|
||||
{
|
||||
BlacklistingEnabled = followerPolicy == ModerationTypeEnum.BlackListing ||
|
||||
twitterAccountPolicy == ModerationTypeEnum.BlackListing,
|
||||
WhitelistingEnabled = followerPolicy == ModerationTypeEnum.WhiteListing ||
|
||||
twitterAccountPolicy == ModerationTypeEnum.WhiteListing,
|
||||
InstanceSaturation = 16,
|
||||
InstanceSaturation = saturation,
|
||||
};
|
||||
|
||||
viewModel = new NodeInfoViewModel
|
||||
{
|
||||
BlacklistingEnabled = false,
|
||||
WhitelistingEnabled = false,
|
||||
InstanceSaturation = 175
|
||||
};
|
||||
//viewModel = new NodeInfoViewModel
|
||||
//{
|
||||
// BlacklistingEnabled = false,
|
||||
// WhitelistingEnabled = false,
|
||||
// InstanceSaturation = 175
|
||||
//};
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue