Optimize database queries, add resilience with is_countable, refine UI for progress bars and tables, update scripts for dynamic resizing, and correct navbar link case sensitivity.

This commit is contained in:
2025-08-20 20:38:01 +02:00
parent 70af042b7b
commit a17bb63889
6 changed files with 96 additions and 51 deletions

View File

@@ -145,7 +145,7 @@
// Backup OK
$answers = Invoke_infra("SELECT * FROM VMs_Backup where ( Owner like 'DUN-VMH%' or Owner like 'MDK-VMH%' ) and name not like 'WS%' and owner not like '%WKG%' and owner not like '%VMH-WM%' and Exclusion ='' and LastResult = 'OK' and TRY_CAST(lastknowngood AS DATE) >= CAST(DATEADD(DAY, -2, GETDATE()) AS DATE) order by name");
$total = count($answers);
$total = is_countable($answers) ? count($answers) : 0;
foreach ($answers as $row) {
$date1 = date_create($row['LastKnownGood']); $diff = date_diff($date1, date_create(date("Y-m-d")));
if(date('w') >= 2 && date('w') <= 6 ){

View File

@@ -45,7 +45,7 @@
<div class="row">
<?php
// =================================================================
// STEP 1: Fetch all required data with minimal database queries (MSSQL SYNTAX)
// STEP 1: Fetch all required data with minimal database queries
// =================================================================
// Query 1: Get aggregated data for all clusters at once.
@@ -198,8 +198,8 @@
$p2 = ($total_vms > 0) ? ($owner2_count / $total_vms) * 100 : 0;
$vm_dist_html = "<div class='progress' style='border: 2px solid grey; height: 20px;'>
<div class='progress-bar text-white' role='progressbar' style='width:$p1%'><b>$owner1_name: $owner1_count</b></div>
<div class='progress-bar bg-info text-dark' role='progressbar' style='width:$p2%'><b>$owner2_name: $owner2_count</b></div>
<div class='progress-bar text-white' role='progressbar' style='width:$p1%'><b>$owner1_name</b></div>
<div class='progress-bar bg-info text-dark' role='progressbar' style='width:$p2%'><b>$owner2_name</b></div>
</div>";
}
}