info('Starting outbound calls reports generation...'); if ($this->option('date')) { $date = Carbon::parse($this->option('date'))->format('Y-m-d'); $this->newLine(); $count = $service->generateDailyOutboundCalls( $date, fn($msg) => $this->line(" [{$date}] {$msg}") ); $this->newLine(); $this->info("Generated {$count} outbound calls for {$date}"); return Command::SUCCESS; } $startDate = $this->option('start-date') ? Carbon::parse($this->option('start-date')) : Carbon::today(); $endDate = $this->option('end-date') ? Carbon::parse($this->option('end-date')) : Carbon::today(); if ($startDate->gt($endDate)) { $this->error('Start date must be before or equal to end date'); return Command::FAILURE; } $totalDays = $startDate->clone()->diffInDays($endDate) + 1; $padLen = strlen((string) $totalDays); $dayIndex = 0; $totalRecords = 0; $overallStart = microtime(true); $current = $startDate->clone(); while ($current->lte($endDate)) { $date = $current->format('Y-m-d'); $dayIndex++; $prefix = sprintf('[%s/%s] %s ', str_pad($dayIndex, $padLen), $totalDays, $date); $count = $service->generateDailyOutboundCalls( $date, fn($msg) => $this->line(" {$prefix}{$msg}") ); $totalRecords += $count; $this->info(" {$prefix}→ {$count} records"); $current->addDay(); } $elapsed = round(microtime(true) - $overallStart, 1); $this->newLine(); $this->info("Total: {$totalRecords} records across {$totalDays} day(s) ({$elapsed}s)"); return Command::SUCCESS; } }