From a572ee354fccf555c141e6c765dcd6cb5f213185 Mon Sep 17 00:00:00 2001 From: fukusuket <41001169+fukusuket@users.noreply.github.com> Date: Sun, 16 Mar 2025 19:22:36 +0900 Subject: [PATCH] update --- WELA.ps1 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/WELA.ps1 b/WELA.ps1 index 9f0b05ef..52ffa52e 100644 --- a/WELA.ps1 +++ b/WELA.ps1 @@ -68,15 +68,20 @@ function Get-RuleCounts { function CalculateUsableRate { param ($counts, $totalCounts) - $counts | ForEach-Object { - $total = ($totalCounts | Where-Object Level -match $PSItem.Level | Select-Object -ExpandProperty Count)[0] - [PSCustomObject]@{ - Level = $PSItem.Level - UsableCount = $PSItem.Count + $result = @() + $totalCounts | ForEach-Object { + $level = $_.Level + $total = $_.Count + $usableCount = ($counts | Where-Object Level -eq $level | Select-Object -ExpandProperty Count -First 1) -or 0 + $percentage = if ($total -ne 0) { "{0:N2}" -f ($usableCount / $total * 100) } else { "0.00" } + $result += [PSCustomObject]@{ + Level = $level + UsableCount = $usableCount TotalCount = $total - Percentage = "{0:N2}" -f ($PSItem.Count / $total * 100) + Percentage = $percentage } } + return $result } function ShowRulesCountsByLevel {