retrieval of dynamic values
This commit is contained in:
parent
bf660b80f6
commit
45255fa39d
|
@ -2,7 +2,9 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.Domain.Repository;
|
using BirdsiteLive.Domain.Repository;
|
||||||
|
using BirdsiteLive.Statistics.Domain;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace BirdsiteLive.Component
|
namespace BirdsiteLive.Component
|
||||||
|
@ -10,34 +12,42 @@ namespace BirdsiteLive.Component
|
||||||
public class NodeInfoViewComponent : ViewComponent
|
public class NodeInfoViewComponent : ViewComponent
|
||||||
{
|
{
|
||||||
private readonly IModerationRepository _moderationRepository;
|
private readonly IModerationRepository _moderationRepository;
|
||||||
|
private readonly ITwitterStatisticsHandler _twitterStatisticsHandler;
|
||||||
|
private readonly ITwitterUserDal _twitterUserDal;
|
||||||
|
|
||||||
#region Ctor
|
#region Ctor
|
||||||
public NodeInfoViewComponent(IModerationRepository moderationRepository)
|
public NodeInfoViewComponent(IModerationRepository moderationRepository, ITwitterStatisticsHandler twitterStatisticsHandler, ITwitterUserDal twitterUserDal)
|
||||||
{
|
{
|
||||||
_moderationRepository = moderationRepository;
|
_moderationRepository = moderationRepository;
|
||||||
|
_twitterStatisticsHandler = twitterStatisticsHandler;
|
||||||
|
_twitterUserDal = twitterUserDal;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public IViewComponentResult Invoke()
|
public async Task<IViewComponentResult> InvokeAsync()
|
||||||
{
|
{
|
||||||
var followerPolicy = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.Follower);
|
var followerPolicy = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.Follower);
|
||||||
var twitterAccountPolicy = _moderationRepository.GetModerationType(ModerationEntityTypeEnum.TwitterAccount);
|
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
|
var viewModel = new NodeInfoViewModel
|
||||||
{
|
{
|
||||||
BlacklistingEnabled = followerPolicy == ModerationTypeEnum.BlackListing ||
|
BlacklistingEnabled = followerPolicy == ModerationTypeEnum.BlackListing ||
|
||||||
twitterAccountPolicy == ModerationTypeEnum.BlackListing,
|
twitterAccountPolicy == ModerationTypeEnum.BlackListing,
|
||||||
WhitelistingEnabled = followerPolicy == ModerationTypeEnum.WhiteListing ||
|
WhitelistingEnabled = followerPolicy == ModerationTypeEnum.WhiteListing ||
|
||||||
twitterAccountPolicy == ModerationTypeEnum.WhiteListing,
|
twitterAccountPolicy == ModerationTypeEnum.WhiteListing,
|
||||||
InstanceSaturation = 16,
|
InstanceSaturation = saturation,
|
||||||
};
|
};
|
||||||
|
|
||||||
viewModel = new NodeInfoViewModel
|
//viewModel = new NodeInfoViewModel
|
||||||
{
|
//{
|
||||||
BlacklistingEnabled = false,
|
// BlacklistingEnabled = false,
|
||||||
WhitelistingEnabled = false,
|
// WhitelistingEnabled = false,
|
||||||
InstanceSaturation = 175
|
// InstanceSaturation = 175
|
||||||
};
|
//};
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue