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";