Fix daily_summary dan hourly_summary aggregation, tambah fallback logic untuk dashboard, update validator untuk camera dan location type

This commit is contained in:
mwpn
2025-12-18 11:13:06 +07:00
parent 9416de7d87
commit d05fa2f4cd
31 changed files with 2041 additions and 45 deletions

View File

@@ -0,0 +1,64 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
use App\Config\AppConfig;
use App\Support\Database;
AppConfig::loadEnv(__DIR__ . '/..');
$db = Database::getConnection(
AppConfig::get('DB_HOST'),
AppConfig::get('DB_NAME'),
AppConfig::get('DB_USER'),
AppConfig::get('DB_PASS')
);
// Get all dates with entry_events
$stmt = $db->query('SELECT DISTINCT DATE(event_time) as date FROM entry_events ORDER BY date DESC');
$dates = $stmt->fetchAll();
echo "=== Running daily_summary for all dates with entry_events ===\n\n";
foreach ($dates as $dateRow) {
$date = $dateRow['date'];
// Skip old/invalid dates
if ($date < '2020-01-01') {
echo "Skipping old date: $date\n";
continue;
}
echo "Processing: $date\n";
// Run daily_summary for this date
$command = sprintf(
'php %s/bin/daily_summary.php %s',
escapeshellarg(__DIR__ . '/..'),
escapeshellarg($date)
);
$output = [];
$returnCode = 0;
exec($command, $output, $returnCode);
if ($returnCode === 0) {
echo " ✓ Success\n";
if (!empty($output)) {
foreach ($output as $line) {
echo " $line\n";
}
}
} else {
echo " ✗ Failed (return code: $returnCode)\n";
if (!empty($output)) {
foreach ($output as $line) {
echo " $line\n";
}
}
}
echo "\n";
}
echo "=== Done ===\n";