Refactor stats variable names for clarity

Renamed generic 'stats' variables to more specific names such as 'domainStats', 'errorStats', 'tldStats', and 'importStats' across controllers and views. This improves code readability and reduces ambiguity when handling different types of statistics in the application.
This commit is contained in:
Hosteroid
2025-10-20 19:53:28 +03:00
parent 1b84f06c86
commit c4e4196e02
8 changed files with 35 additions and 35 deletions

View File

@@ -41,7 +41,7 @@ class ErrorLogController extends Controller
$errors = $this->errorLogModel->getPaginatedErrors($filters, $perPage, $offset); $errors = $this->errorLogModel->getPaginatedErrors($filters, $perPage, $offset);
// Get statistics using model // Get statistics using model
$stats = $this->errorLogModel->getAdminStats(); $errorStats = $this->errorLogModel->getAdminStats();
// Pagination data // Pagination data
$totalPages = ceil($totalErrors / $perPage); $totalPages = ceil($totalErrors / $perPage);
@@ -54,7 +54,7 @@ class ErrorLogController extends Controller
'showing_to' => min($offset + $perPage, $totalErrors) 'showing_to' => min($offset + $perPage, $totalErrors)
]; ];
$this->view('errors/admin-index', compact('errors', 'stats', 'filters', 'pagination')); $this->view('errors/admin-index', compact('errors', 'errorStats', 'filters', 'pagination'));
} }
/** /**

View File

@@ -37,12 +37,12 @@ class TldRegistryController extends Controller
$order = $_GET['order'] ?? 'asc'; $order = $_GET['order'] ?? 'asc';
$result = $this->tldModel->getPaginated($page, $perPage, $search, $sort, $order, $status, $dataType); $result = $this->tldModel->getPaginated($page, $perPage, $search, $sort, $order, $status, $dataType);
$stats = $this->tldModel->getStatistics(); $tldStats = $this->tldModel->getStatistics();
$this->view('tld-registry/index', [ $this->view('tld-registry/index', [
'tlds' => $result['tlds'], 'tlds' => $result['tlds'],
'pagination' => $result['pagination'], 'pagination' => $result['pagination'],
'stats' => $stats, 'tldStats' => $tldStats,
'filters' => [ 'filters' => [
'search' => $search, 'search' => $search,
'status' => $status, 'status' => $status,
@@ -584,7 +584,7 @@ class TldRegistryController extends Controller
$this->view('tld-registry/import-logs', [ $this->view('tld-registry/import-logs', [
'imports' => $result['logs'], 'imports' => $result['logs'],
'pagination' => $result['pagination'], 'pagination' => $result['pagination'],
'stats' => $importStats, 'importStats' => $importStats,
'title' => 'TLD Import Logs' 'title' => 'TLD Import Logs'
]); ]);
} }

View File

@@ -4,9 +4,9 @@ $pageTitle = 'Dashboard Overview';
$pageDescription = 'Monitor your domains and expiration dates'; $pageDescription = 'Monitor your domains and expiration dates';
$pageIcon = 'fas fa-chart-line'; $pageIcon = 'fas fa-chart-line';
// Get stats for dashboard (if not already set by base.php) // Get domain stats for dashboard (if not already set by base.php)
if (!isset($stats)) { if (!isset($domainStats)) {
$stats = \App\Helpers\LayoutHelper::getDomainStats(); $domainStats = \App\Helpers\LayoutHelper::getDomainStats();
} }
ob_start(); ob_start();
@@ -19,7 +19,7 @@ ob_start();
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Total Domains</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Total Domains</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['total'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $domainStats['total'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-blue-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-blue-50 rounded-lg flex items-center justify-center">
<i class="fas fa-globe text-blue-600 text-lg"></i> <i class="fas fa-globe text-blue-600 text-lg"></i>
@@ -32,7 +32,7 @@ ob_start();
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Active</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Active</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['active'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $domainStats['active'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-green-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-green-50 rounded-lg flex items-center justify-center">
<i class="fas fa-check-circle text-green-600 text-lg"></i> <i class="fas fa-check-circle text-green-600 text-lg"></i>
@@ -45,8 +45,8 @@ ob_start();
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Expiring Soon</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Expiring Soon</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['expiring_soon'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $domainStats['expiring_soon'] ?? 0 ?></p>
<p class="text-xs text-gray-400 mt-1">within <?= $stats['expiring_threshold'] ?? 30 ?> days</p> <p class="text-xs text-gray-400 mt-1">within <?= $domainStats['expiring_threshold'] ?? 30 ?> days</p>
</div> </div>
<div class="w-12 h-12 bg-orange-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-orange-50 rounded-lg flex items-center justify-center">
<i class="fas fa-exclamation-triangle text-orange-600 text-lg"></i> <i class="fas fa-exclamation-triangle text-orange-600 text-lg"></i>
@@ -59,7 +59,7 @@ ob_start();
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Inactive</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Inactive</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['inactive'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $domainStats['inactive'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-gray-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-gray-50 rounded-lg flex items-center justify-center">
<i class="fas fa-times-circle text-gray-600 text-lg"></i> <i class="fas fa-times-circle text-gray-600 text-lg"></i>
@@ -261,7 +261,7 @@ ob_start();
<div class="p-6 text-center"> <div class="p-6 text-center">
<i class="fas fa-check-circle text-green-500 text-3xl mb-2"></i> <i class="fas fa-check-circle text-green-500 text-3xl mb-2"></i>
<p class="text-sm text-gray-600">No domains expiring soon</p> <p class="text-sm text-gray-600">No domains expiring soon</p>
<p class="text-xs text-gray-400 mt-1">within <?= $stats['expiring_threshold'] ?? 30 ?> days</p> <p class="text-xs text-gray-400 mt-1">within <?= $domainStats['expiring_threshold'] ?? 30 ?> days</p>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>

View File

@@ -34,7 +34,7 @@ $currentFilters = $filters ?? ['resolved' => '', 'type' => '', 'sort' => 'last_o
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Total Errors</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Total Errors</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['total_errors'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $errorStats['total_errors'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-red-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-red-50 rounded-lg flex items-center justify-center">
<i class="fas fa-exclamation-triangle text-red-600 text-lg"></i> <i class="fas fa-exclamation-triangle text-red-600 text-lg"></i>
@@ -47,7 +47,7 @@ $currentFilters = $filters ?? ['resolved' => '', 'type' => '', 'sort' => 'last_o
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Unresolved</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Unresolved</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['unresolved'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $errorStats['unresolved'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-orange-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-orange-50 rounded-lg flex items-center justify-center">
<i class="fas fa-exclamation-circle text-orange-600 text-lg"></i> <i class="fas fa-exclamation-circle text-orange-600 text-lg"></i>
@@ -60,7 +60,7 @@ $currentFilters = $filters ?? ['resolved' => '', 'type' => '', 'sort' => 'last_o
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Last 24h</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Last 24h</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['last_24h'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $errorStats['last_24h'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-blue-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-blue-50 rounded-lg flex items-center justify-center">
<i class="fas fa-clock text-blue-600 text-lg"></i> <i class="fas fa-clock text-blue-600 text-lg"></i>
@@ -73,7 +73,7 @@ $currentFilters = $filters ?? ['resolved' => '', 'type' => '', 'sort' => 'last_o
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Occurrences</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Occurrences</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['total_occurrences'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $errorStats['total_occurrences'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-indigo-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-indigo-50 rounded-lg flex items-center justify-center">
<i class="fas fa-layer-group text-indigo-600 text-lg"></i> <i class="fas fa-layer-group text-indigo-600 text-lg"></i>

View File

@@ -17,9 +17,9 @@ if ($userId) {
$unreadNotifications = 0; $unreadNotifications = 0;
} }
// Get stats for sidebar (available on all pages) // Get domain stats for sidebar (available on all pages)
if (!isset($stats)) { if (!isset($domainStats)) {
$stats = \App\Helpers\LayoutHelper::getDomainStats(); $domainStats = \App\Helpers\LayoutHelper::getDomainStats();
} }
// Get application settings from database // Get application settings from database

View File

@@ -84,7 +84,7 @@
</div> </div>
<span class="text-gray-400 text-xs">Total</span> <span class="text-gray-400 text-xs">Total</span>
</div> </div>
<span class="text-white font-semibold text-sm"><?= $stats['total'] ?? 0 ?></span> <span class="text-white font-semibold text-sm"><?= $domainStats['total'] ?? 0 ?></span>
</div> </div>
</div> </div>
@@ -94,9 +94,9 @@
<div class="w-7 h-7 bg-orange-500/20 rounded flex items-center justify-center mr-2.5"> <div class="w-7 h-7 bg-orange-500/20 rounded flex items-center justify-center mr-2.5">
<i class="fas fa-exclamation-triangle text-orange-400 text-xs"></i> <i class="fas fa-exclamation-triangle text-orange-400 text-xs"></i>
</div> </div>
<span class="text-gray-400 text-xs" title="Within <?= $stats['expiring_threshold'] ?? 30 ?> days">Expiring</span> <span class="text-gray-400 text-xs" title="Within <?= $domainStats['expiring_threshold'] ?? 30 ?> days">Expiring</span>
</div> </div>
<span class="text-orange-400 font-semibold text-sm"><?= $stats['expiring_soon'] ?? 0 ?></span> <span class="text-orange-400 font-semibold text-sm"><?= $domainStats['expiring_soon'] ?? 0 ?></span>
</div> </div>
</div> </div>
@@ -108,7 +108,7 @@
</div> </div>
<span class="text-gray-400 text-xs">Active</span> <span class="text-gray-400 text-xs">Active</span>
</div> </div>
<span class="text-green-400 font-semibold text-sm"><?= $stats['active'] ?? 0 ?></span> <span class="text-green-400 font-semibold text-sm"><?= $domainStats['active'] ?? 0 ?></span>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -27,7 +27,7 @@ ob_start();
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Total Imports</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Total Imports</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['total_imports'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $importStats['total_imports'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-blue-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-blue-50 rounded-lg flex items-center justify-center">
<i class="fas fa-download text-blue-600 text-lg"></i> <i class="fas fa-download text-blue-600 text-lg"></i>
@@ -40,7 +40,7 @@ ob_start();
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Successful</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Successful</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['successful_imports'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $importStats['successful_imports'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-green-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-green-50 rounded-lg flex items-center justify-center">
<i class="fas fa-check-circle text-green-600 text-lg"></i> <i class="fas fa-check-circle text-green-600 text-lg"></i>
@@ -53,7 +53,7 @@ ob_start();
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Failed</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Failed</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['failed_imports'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $importStats['failed_imports'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-red-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-red-50 rounded-lg flex items-center justify-center">
<i class="fas fa-times-circle text-red-600 text-lg"></i> <i class="fas fa-times-circle text-red-600 text-lg"></i>
@@ -67,8 +67,8 @@ ob_start();
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Last Import</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Last Import</p>
<p class="text-sm font-semibold text-gray-900 mt-1"> <p class="text-sm font-semibold text-gray-900 mt-1">
<?php if (!empty($stats['last_import'])): ?> <?php if (!empty($importStats['last_import'])): ?>
<?= date('M j, H:i', strtotime($stats['last_import'])) ?> <?= date('M j, H:i', strtotime($importStats['last_import'])) ?>
<?php else: ?> <?php else: ?>
Never Never
<?php endif; ?> <?php endif; ?>

View File

@@ -37,7 +37,7 @@ $currentFilters = $filters ?? ['search' => '', 'sort' => 'tld', 'order' => 'asc'
<form method="POST" action="/tld-registry/start-progressive-import" class="inline"> <form method="POST" action="/tld-registry/start-progressive-import" class="inline">
<?= csrf_field() ?> <?= csrf_field() ?>
<input type="hidden" name="import_type" value="check_updates"> <input type="hidden" name="import_type" value="check_updates">
<button type="submit" <?= $stats['total'] == 0 ? 'disabled' : '' ?> class="inline-flex items-center px-4 py-2 <?= $stats['total'] == 0 ? 'bg-gray-400 cursor-not-allowed' : 'bg-indigo-600 hover:bg-indigo-700' ?> text-white text-sm rounded-lg transition-colors font-medium" title="<?= $stats['total'] == 0 ? 'Import TLDs first' : 'Check for IANA updates' ?>"> <button type="submit" <?= $tldStats['total'] == 0 ? 'disabled' : '' ?> class="inline-flex items-center px-4 py-2 <?= $tldStats['total'] == 0 ? 'bg-gray-400 cursor-not-allowed' : 'bg-indigo-600 hover:bg-indigo-700' ?> text-white text-sm rounded-lg transition-colors font-medium" title="<?= $tldStats['total'] == 0 ? 'Import TLDs first' : 'Check for IANA updates' ?>">
<i class="fas fa-sync-alt mr-2"></i> <i class="fas fa-sync-alt mr-2"></i>
Check Updates Check Updates
</button> </button>
@@ -69,7 +69,7 @@ $currentFilters = $filters ?? ['search' => '', 'sort' => 'tld', 'order' => 'asc'
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Total TLDs</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Total TLDs</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['total'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $tldStats['total'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-blue-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-blue-50 rounded-lg flex items-center justify-center">
<i class="fas fa-globe text-blue-600 text-lg"></i> <i class="fas fa-globe text-blue-600 text-lg"></i>
@@ -82,7 +82,7 @@ $currentFilters = $filters ?? ['search' => '', 'sort' => 'tld', 'order' => 'asc'
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Active</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">Active</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['active'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $tldStats['active'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-green-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-green-50 rounded-lg flex items-center justify-center">
<i class="fas fa-check-circle text-green-600 text-lg"></i> <i class="fas fa-check-circle text-green-600 text-lg"></i>
@@ -95,7 +95,7 @@ $currentFilters = $filters ?? ['search' => '', 'sort' => 'tld', 'order' => 'asc'
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">With RDAP</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">With RDAP</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['with_rdap'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $tldStats['with_rdap'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-indigo-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-indigo-50 rounded-lg flex items-center justify-center">
<i class="fas fa-database text-indigo-600 text-lg"></i> <i class="fas fa-database text-indigo-600 text-lg"></i>
@@ -108,7 +108,7 @@ $currentFilters = $filters ?? ['search' => '', 'sort' => 'tld', 'order' => 'asc'
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
<p class="text-xs font-medium text-gray-500 uppercase tracking-wide">With WHOIS</p> <p class="text-xs font-medium text-gray-500 uppercase tracking-wide">With WHOIS</p>
<p class="text-2xl font-semibold text-gray-900 mt-1"><?= $stats['with_whois'] ?? 0 ?></p> <p class="text-2xl font-semibold text-gray-900 mt-1"><?= $tldStats['with_whois'] ?? 0 ?></p>
</div> </div>
<div class="w-12 h-12 bg-orange-50 rounded-lg flex items-center justify-center"> <div class="w-12 h-12 bg-orange-50 rounded-lg flex items-center justify-center">
<i class="fas fa-server text-orange-600 text-lg"></i> <i class="fas fa-server text-orange-600 text-lg"></i>