change stats on homepage
This commit is contained in:
parent
9026273f45
commit
83842f5874
5 changed files with 23 additions and 18 deletions
|
@ -37,7 +37,8 @@ namespace BirdsiteLive.Component
|
||||||
twitterAccountPolicy == ModerationTypeEnum.BlackListing,
|
twitterAccountPolicy == ModerationTypeEnum.BlackListing,
|
||||||
WhitelistingEnabled = followerPolicy == ModerationTypeEnum.WhiteListing ||
|
WhitelistingEnabled = followerPolicy == ModerationTypeEnum.WhiteListing ||
|
||||||
twitterAccountPolicy == ModerationTypeEnum.WhiteListing,
|
twitterAccountPolicy == ModerationTypeEnum.WhiteListing,
|
||||||
InstanceSaturation = statistics.Saturation
|
InstanceSaturation = statistics.Saturation,
|
||||||
|
SyncLag = statistics.SyncLag
|
||||||
};
|
};
|
||||||
|
|
||||||
//viewModel = new NodeInfoViewModel
|
//viewModel = new NodeInfoViewModel
|
||||||
|
@ -55,5 +56,6 @@ namespace BirdsiteLive.Component
|
||||||
public bool BlacklistingEnabled { get; set; }
|
public bool BlacklistingEnabled { get; set; }
|
||||||
public bool WhitelistingEnabled { get; set; }
|
public bool WhitelistingEnabled { get; set; }
|
||||||
public int InstanceSaturation { get; set; }
|
public int InstanceSaturation { get; set; }
|
||||||
|
public TimeSpan SyncLag { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,12 +32,14 @@ namespace BirdsiteLive.Services
|
||||||
{
|
{
|
||||||
var twitterUserMax = _instanceSettings.MaxUsersCapacity;
|
var twitterUserMax = _instanceSettings.MaxUsersCapacity;
|
||||||
var twitterUserCount = await _twitterUserDal.GetTwitterUsersCountAsync();
|
var twitterUserCount = await _twitterUserDal.GetTwitterUsersCountAsync();
|
||||||
|
var twitterSyncLag = await _twitterUserDal.GetTwitterSyncLag();
|
||||||
var saturation = (int)((double)twitterUserCount / twitterUserMax * 100);
|
var saturation = (int)((double)twitterUserCount / twitterUserMax * 100);
|
||||||
|
|
||||||
_cachedStatistics = new CachedStatistics
|
_cachedStatistics = new CachedStatistics
|
||||||
{
|
{
|
||||||
RefreshedTime = DateTime.UtcNow,
|
RefreshedTime = DateTime.UtcNow,
|
||||||
Saturation = saturation
|
Saturation = saturation,
|
||||||
|
SyncLag = twitterSyncLag
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +50,7 @@ namespace BirdsiteLive.Services
|
||||||
public class CachedStatistics
|
public class CachedStatistics
|
||||||
{
|
{
|
||||||
public DateTime RefreshedTime { get; set; }
|
public DateTime RefreshedTime { get; set; }
|
||||||
|
public TimeSpan SyncLag { get; set; }
|
||||||
public int Saturation { get; set; }
|
public int Saturation { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,22 +1,10 @@
|
||||||
@model BirdsiteLive.Component.NodeInfoViewModel
|
@model BirdsiteLive.Component.NodeInfoViewModel
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@if (ViewData.Model.WhitelistingEnabled)
|
|
||||||
{
|
|
||||||
<a asp-controller="About" asp-action="Whitelisting" class="badge badge-light" title="What does this mean?">Whitelisting Enabled</a>
|
|
||||||
}
|
|
||||||
@if (ViewData.Model.BlacklistingEnabled)
|
|
||||||
{
|
|
||||||
<a asp-controller="About" asp-action="Blacklisting" class="badge badge-light" title="What does this mean?">Blacklisting Enabled</a>
|
|
||||||
}
|
|
||||||
|
|
||||||
<div class="node-progress-bar">
|
<div class="node-progress-bar">
|
||||||
<div class="node-progress-bar__label"><a asp-controller="About" asp-action="Index">Instance saturation:</a></div>
|
<div class="node-progress-bar__label">
|
||||||
<div class="progress node-progress-bar__bar">
|
<a asp-controller="About" asp-action="Index">Service load:</a>
|
||||||
<div class="progress-bar
|
@Math.Ceiling(ViewData.Model.SyncLag.TotalMinutes) minutes to fetch all twitter users
|
||||||
@((ViewData.Model.InstanceSaturation > 50 && ViewData.Model.InstanceSaturation < 75) ? "bg-warning ":"")
|
</div>
|
||||||
@((ViewData.Model.InstanceSaturation > 75 && ViewData.Model.InstanceSaturation < 100) ? "bg-danger ":"")
|
|
||||||
@((ViewData.Model.InstanceSaturation > 100) ? "bg-saturation-danger ":"")" style="width: @ViewData.Model.InstanceSaturation%">@ViewData.Model.InstanceSaturation%</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -85,6 +85,17 @@ namespace BirdsiteLive.DAL.Postgres.DataAccessLayers
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<TimeSpan> GetTwitterSyncLag()
|
||||||
|
{
|
||||||
|
var query = $"SELECT max(lastsync) - min(lastsync) as diff FROM (SELECT unnest(followings) as follow FROM followers GROUP BY follow) AS f INNER JOIN twitter_users ON f.follow=twitter_users.id;";
|
||||||
|
|
||||||
|
using (var dbConnection = Connection)
|
||||||
|
{
|
||||||
|
var result = (await dbConnection.QueryAsync<TimeSpan>(query)).FirstOrDefault();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<int> GetTwitterUsersCountAsync()
|
public async Task<int> GetTwitterUsersCountAsync()
|
||||||
{
|
{
|
||||||
var query = $"SELECT COUNT(*) FROM {_settings.TwitterUserTableName}";
|
var query = $"SELECT COUNT(*) FROM {_settings.TwitterUserTableName}";
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace BirdsiteLive.DAL.Contracts
|
||||||
Task DeleteTwitterUserAsync(string acct);
|
Task DeleteTwitterUserAsync(string acct);
|
||||||
Task DeleteTwitterUserAsync(int id);
|
Task DeleteTwitterUserAsync(int id);
|
||||||
Task<int> GetTwitterUsersCountAsync();
|
Task<int> GetTwitterUsersCountAsync();
|
||||||
|
Task<TimeSpan> GetTwitterSyncLag();
|
||||||
Task<int> GetFailingTwitterUsersCountAsync();
|
Task<int> GetFailingTwitterUsersCountAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue