daily_collection_stats, weekly_route_performance, monthly_store_sales aggregation tables. Aggregator service is idempotent — wipes the slice and re-inserts. php artisan reports:aggregate (default: yesterday) for the nightly cron. Admin endpoints: daily-collection / trip-performance / store-sales chart series + totals, compliance.csv stream of dumpsite releases (DENR-style), POST rebuild for on-demand aggregation. Payments, notifications, and live tracking sub-modules of Module 13 are deferred per scope. 164 feature tests passing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
34 lines
961 B
PHP
34 lines
961 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\Report\Aggregator;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class AggregateReports extends Command
|
|
{
|
|
protected $signature = 'reports:aggregate {--date= : Reference date (default: yesterday)}';
|
|
|
|
protected $description = 'Recompute daily, weekly, and monthly aggregations for the given date';
|
|
|
|
public function handle(Aggregator $agg): int
|
|
{
|
|
$date = $this->option('date')
|
|
? Carbon::parse($this->option('date'))
|
|
: Carbon::yesterday();
|
|
|
|
$daily = $agg->rebuildDailyCollectionStats($date);
|
|
$weekly = $agg->rebuildWeeklyRoutePerformance($date);
|
|
$monthly = $agg->rebuildMonthlyStoreSales($date);
|
|
|
|
$this->info(sprintf(
|
|
'Aggregated for %s — daily:%d weekly:%d monthly:%d',
|
|
$date->toDateString(),
|
|
$daily, $weekly, $monthly,
|
|
));
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|