Show dismissed case count on mod panel

This commit is contained in:
jvyden 2022-08-05 22:02:55 -04:00
commit 22fc2ead98
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
5 changed files with 37 additions and 5 deletions

View file

@ -38,4 +38,16 @@ else
@await Html.PartialAsync("Partials/AdminPanelStatisticPartial", statistic)
<br>
}
}
}
<h2>Actions</h2>
<a href="/moderation/bannedUsers" class="ui red button">
<i class="users icon"></i>
<span>View banned users</span>
</a><br/><br/>
<a href="/moderation/hiddenSlots" class="ui yellow button">
<i class="certificate icon"></i>
<span>View hidden levels</span>
</a>

View file

@ -19,8 +19,18 @@ public class ModPanelPage : BaseLayout
if (user == null) return this.Redirect("~/login");
if (!user.IsModerator) return this.NotFound();
this.Statistics.Add(new AdminPanelStatistic("Reports", await StatisticsHelper.ReportCount(), "/moderation/reports/0"));
this.Statistics.Add(new AdminPanelStatistic("Cases", await StatisticsHelper.CaseCount(), "/moderation/cases/0"));
this.Statistics.Add(new AdminPanelStatistic(
statisticNamePlural: "Reports",
count: await StatisticsHelper.ReportCount(),
viewAllEndpoint: "/moderation/reports/0")
);
this.Statistics.Add(new AdminPanelStatistic(
statisticNamePlural: "Cases",
count: await StatisticsHelper.DismissedCaseCount(),
viewAllEndpoint: "/moderation/cases/0",
secondStatistic: await StatisticsHelper.CaseCount())
);
return this.Page();
}

View file

@ -12,6 +12,13 @@
{
<h2>@Model.StatisticNamePlural</h2>
}
<h3>@Model.Count</h3>
@if (Model.SecondStatistic == null)
{
<h3>@Model.Count</h3>
}
else
{
<h3>@Model.Count / @Model.SecondStatistic</h3>
}
</div>
</div>

View file

@ -4,15 +4,17 @@ namespace LBPUnion.ProjectLighthouse.Administration;
public struct AdminPanelStatistic
{
public AdminPanelStatistic(string statisticNamePlural, int count, string? viewAllEndpoint = null)
public AdminPanelStatistic(string statisticNamePlural, int count, string? viewAllEndpoint = null, int? secondStatistic = null)
{
this.StatisticNamePlural = statisticNamePlural;
this.Count = count;
this.SecondStatistic = secondStatistic;
this.ViewAllEndpoint = viewAllEndpoint;
}
public readonly string StatisticNamePlural;
public readonly int Count;
public readonly int? SecondStatistic;
public readonly string? ViewAllEndpoint;
}

View file

@ -28,6 +28,7 @@ public static class StatisticsHelper
#region Moderator/Admin specific
public static async Task<int> ReportCount() => await database.Reports.CountAsync();
public static async Task<int> CaseCount() => await database.Cases.CountAsync();
public static async Task<int> DismissedCaseCount() => await database.Cases.CountAsync(c => c.DismissedAt != null);
#endregion
public static async Task<int> APIKeyCount() => await database.APIKeys.CountAsync();