Skip to content

Commit

Permalink
Format ratio as 1:x or x:1
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Mar 8, 2023
1 parent f5e741c commit f3dae7a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Hammer/Services/InfractionStatisticsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,18 @@ public async Task<DiscordEmbed> CreateStatisticsEmbedAsync(DiscordGuild guild)
int usersWarnedCount = GetDistinctWarnedUsers(guild);
int totalMessagesDeletedCount = await GetTotalDeletedMessageCountAsync(guild).ConfigureAwait(false);

(float A, float B) banRatio = Ratio(permBanCount, tempBanCount);
(float A, float B) muteRatio = Ratio(permMuteCount, tempMuteCount);
var banRatioFormatted = $"{permBanCount:N0} perm / {tempBanCount} temp ({banRatio.A:N} : {banRatio.B:N})";
var muteRatioFormatted = $"{permMuteCount:N0} perm / {tempMuteCount} temp ({muteRatio.A:N} : {muteRatio.B:N})";
(int A, int B) banRatio = Ratio(permBanCount, tempBanCount);
(int A, int B) muteRatio = Ratio(permMuteCount, tempMuteCount);
float minBan = Math.Min(banRatio.A, banRatio.B);
float maxBan = Math.Max(banRatio.A, banRatio.B);
float minMute = Math.Min(muteRatio.A, muteRatio.B);
float maxMute = Math.Max(muteRatio.A, muteRatio.B);

string banRatioFormatted = $"{permBanCount:N0} perm / {tempBanCount} temp\n" +
(banRatio.A > banRatio.B ? $"({maxBan / minBan} : 1)" : $"(1 : {maxBan / minBan:N2})");

string muteRatioFormatted = $"{permMuteCount:N0} perm / {tempMuteCount} temp\n" +
(muteRatio.A > muteRatio.B ? $"({maxMute / minMute} : 1)" : $"(1 : {maxMute / minMute:N2})");

TimeSpan remainingBanTime = GetRemainingBanTime(guild);
TimeSpan remainingMuteTime = GetRemainingMuteTime(guild);
Expand Down

0 comments on commit f3dae7a

Please sign in to comment.