From 0e6ec0902d43e0b767ac5a64ff885bc99635f5d7 Mon Sep 17 00:00:00 2001 From: Master3395 Date: Sun, 2 Nov 2025 19:54:58 +0100 Subject: [PATCH] Refactor disk and bandwidth limit calculations in getSystemStatus - Updated the calculation of total disk limit and bandwidth limit to convert values from MB to GB for better clarity in the system status display. - Ensured default values are maintained when limits are not set, enhancing the robustness of resource reporting. https://github.com/usmannasir/cyberpanel/issues/1592 --- baseTemplate/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/baseTemplate/views.py b/baseTemplate/views.py index eedf0d871..8b29f2299 100644 --- a/baseTemplate/views.py +++ b/baseTemplate/views.py @@ -174,7 +174,7 @@ def getSystemStatus(request): # Convert MB to GB for display total_disk_used_gb = round(total_disk_used / 1024, 2) - total_disk_limit_gb = total_disk_limit if total_disk_limit > 0 else 100 # Default 100GB if no limit + total_disk_limit_gb = round(total_disk_limit / 1024, 2) if total_disk_limit > 0 else 100 # Default 100GB if no limit disk_free_gb = max(0, total_disk_limit_gb - total_disk_used_gb) disk_usage_percent = min(100, int((total_disk_used_gb / total_disk_limit_gb) * 100)) if total_disk_limit_gb > 0 else 0 @@ -185,7 +185,7 @@ def getSystemStatus(request): if website.package: bandwidth_limit += website.package.bandwidth - bandwidth_limit_gb = bandwidth_limit if bandwidth_limit > 0 else 1000 # Default 1000GB if no limit + bandwidth_limit_gb = round(bandwidth_limit / 1024, 2) if bandwidth_limit > 0 else 1000 # Default 1000GB if no limit bandwidth_usage_percent = 0 # You can implement actual bandwidth tracking here # Count resources