update recently clients to show last 24 hours
fix color codes on profile meta data
This commit is contained in:
parent
524589717b
commit
ede5c9de51
@ -10,7 +10,6 @@ using static SharedLibraryCore.Database.Models.EFClient;
|
|||||||
|
|
||||||
namespace SharedLibraryCore.Services
|
namespace SharedLibraryCore.Services
|
||||||
{
|
{
|
||||||
|
|
||||||
public class ClientService : Interfaces.IEntityService<EFClient>
|
public class ClientService : Interfaces.IEntityService<EFClient>
|
||||||
{
|
{
|
||||||
public async Task<EFClient> Create(EFClient entity)
|
public async Task<EFClient> Create(EFClient entity)
|
||||||
@ -579,19 +578,20 @@ namespace SharedLibraryCore.Services
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<IList<PlayerInfo>> GetRecentClients()
|
public async Task<IList<PlayerInfo>> GetRecentClients()
|
||||||
{
|
{
|
||||||
|
var startOfPeriod = DateTime.UtcNow.AddHours(-24);
|
||||||
|
|
||||||
using (var context = new DatabaseContext(true))
|
using (var context = new DatabaseContext(true))
|
||||||
{
|
{
|
||||||
var iqClients = context.Clients
|
var iqClients = context.Clients
|
||||||
.Where(_client => _client.CurrentAlias.IPAddress != null)
|
.Where(_client => _client.CurrentAlias.IPAddress != null)
|
||||||
|
.Where(_client => _client.LastConnection >= startOfPeriod)
|
||||||
.Select(_client => new PlayerInfo()
|
.Select(_client => new PlayerInfo()
|
||||||
{
|
{
|
||||||
ClientId = _client.ClientId,
|
ClientId = _client.ClientId,
|
||||||
Name = _client.CurrentAlias.Name,
|
Name = _client.CurrentAlias.Name,
|
||||||
IPAddress = _client.CurrentAlias.IPAddress.ConvertIPtoString(),
|
IPAddress = _client.CurrentAlias.IPAddress.ConvertIPtoString(),
|
||||||
LastConnection = _client.FirstConnection
|
LastConnection = _client.FirstConnection
|
||||||
})
|
});
|
||||||
.OrderByDescending(_client => _client.ClientId)
|
|
||||||
.Take(10);
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
var sql = iqClients.ToSql();
|
var sql = iqClients.ToSql();
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
var timeSinceLastEvent = DateTime.MinValue;
|
var timeSinceLastEvent = DateTime.MinValue;
|
||||||
|
|
||||||
string formatPenalty(SharedLibraryCore.Dtos.ProfileMeta meta)
|
dynamic formatPenaltyInfo(SharedLibraryCore.Dtos.ProfileMeta meta)
|
||||||
{
|
{
|
||||||
var penalty = meta.Value as SharedLibraryCore.Dtos.PenaltyInfo;
|
var penalty = meta.Value as SharedLibraryCore.Dtos.PenaltyInfo;
|
||||||
|
|
||||||
@ -15,21 +15,15 @@
|
|||||||
string localizationMessage = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex[localizationKey];
|
string localizationMessage = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex[localizationKey];
|
||||||
var regexMatch = System.Text.RegularExpressions.Regex.Match(localizationMessage, @"^.*{{([^{}]+)}}.+$");
|
var regexMatch = System.Text.RegularExpressions.Regex.Match(localizationMessage, @"^.*{{([^{}]+)}}.+$");
|
||||||
string penaltyType = regexMatch.Groups[1].Value.ToString();
|
string penaltyType = regexMatch.Groups[1].Value.ToString();
|
||||||
|
var secondMatch = System.Text.RegularExpressions.Regex.Match(localizationMessage, @"\{\{.+\}\}(.+)\{0\}(.+)\{1\}");
|
||||||
|
|
||||||
localizationMessage = localizationMessage.Replace(penaltyType, $"<span class='penalties-color-{penalty.PenaltyTypeText.ToLower()}'>{penaltyType}</span>");
|
return new
|
||||||
|
{
|
||||||
return meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized ?
|
Type = meta.Type,
|
||||||
string.Format(localizationMessage,
|
Match = secondMatch,
|
||||||
$"<span class='text-highlight'><a class='link-inverse' href='{penalty.OffenderId}'>{penalty.OffenderName}</a></span>",
|
Penalty = penalty,
|
||||||
$"<span class='{(ViewBag.Authorized ? "automated-penalty-info-detailed" : "")} text-white' data-penalty-id='{penalty.Id}'>{penalty.Offense} {(ViewBag.Authorized ? penalty.AdditionalPenaltyInformation : "")}</span>")
|
PenaltyType = penaltyType
|
||||||
.Replace("{", "")
|
};
|
||||||
.Replace("}", "") :
|
|
||||||
string.Format(localizationMessage,
|
|
||||||
$"<span class='text-highlight'><a class='link-inverse' href='{penalty.PunisherId}'>{penalty.PunisherName}</a></span>",
|
|
||||||
$"<span class='{(ViewBag.Authorized ? "automated-penalty-info-detailed" : "")} text-white' data-penalty-id='{penalty.Id}'>{penalty.Offense} {(ViewBag.Authorized ? penalty.AdditionalPenaltyInformation : "")}</span>",
|
|
||||||
penalty.Offense)
|
|
||||||
.Replace("{", "")
|
|
||||||
.Replace("}", "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +55,40 @@
|
|||||||
break;
|
break;
|
||||||
case SharedLibraryCore.Dtos.ProfileMeta.MetaType.ReceivedPenalty:
|
case SharedLibraryCore.Dtos.ProfileMeta.MetaType.ReceivedPenalty:
|
||||||
case SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized:
|
case SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized:
|
||||||
<div class="profile-meta-entry loader-data-time" data-time="@meta.When"><color-code value="@Html.Raw(formatPenalty(meta))" allow="@ViewBag.EnableColorCodes"></color-code></div>
|
<div class="profile-meta-entry loader-data-time" data-time="@meta.When">
|
||||||
|
@{ var penaltyInfo = formatPenaltyInfo(meta); }
|
||||||
|
@if (meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized)
|
||||||
|
{
|
||||||
|
<span class="penalties-color-@penaltyInfo.Penalty.PenaltyTypeText.ToLower()">@penaltyInfo.PenaltyType</span>
|
||||||
|
<span>@penaltyInfo.Match.Groups[1].ToString()</span> <!-- by -->
|
||||||
|
|
||||||
|
<span class="text-highlight">
|
||||||
|
<!-- punisher -->
|
||||||
|
<a class="link-inverse" href="@penaltyInfo.Penalty.OffenderId">
|
||||||
|
<color-code value="@penaltyInfo.Penalty.OffenderName" allow="@ViewBag.EnableColorCodes"></color-code>
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
<span>@penaltyInfo.Match.Groups[2].ToString()</span> <!-- for -->
|
||||||
|
<span class="@(ViewBag.Authorized ? "automated-penalty-info-detailed" : "")} text-white"
|
||||||
|
data-penalty-id="@penaltyInfo.Penalty.Id"><color-code value="@penaltyInfo.Penalty.Offense" allow="@ViewBag.EnableColorCodes"></color-code> @(ViewBag.Authorized ? penaltyInfo.Penalty.AdditionalPenaltyInformation : "")</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.ReceivedPenalty)
|
||||||
|
{
|
||||||
|
<span class="penalties-color-@penaltyInfo.Penalty.PenaltyTypeText.ToLower()">@penaltyInfo.PenaltyType</span> <!-- actioned -->
|
||||||
|
<span>@penaltyInfo.Match.Groups[1].ToString()</span> <!-- by -->
|
||||||
|
<span class="text-highlight">
|
||||||
|
<a class="link-inverse" href="@penaltyInfo.Penalty.PunisherId">
|
||||||
|
<color-code value="@penaltyInfo.Penalty.PunisherName" allow="@ViewBag.EnableColorCodes"></color-code>
|
||||||
|
</a> <!-- punisher -->
|
||||||
|
</span>
|
||||||
|
<span>@penaltyInfo.Match.Groups[2]</span>
|
||||||
|
<span class="@(ViewBag.Authorized ? "automated-penalty-info-detailed" : "") text-white"
|
||||||
|
data-penalty-id="@penaltyInfo.Penalty.Id">
|
||||||
|
<color-code value="@penaltyInfo.Penalty.Offense" allow="@ViewBag.EnableColorCodes"></color-code> @(ViewBag.Authorized ? penaltyInfo.Penalty.AdditionalPenaltyInformation : "")
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user