<?php

use App\Jobs\PruneAuditLogsJob;
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;

Artisan::command('inspire', function () {
    $this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');

// Shared hosting has no daemons: cPanel's single cron entry runs `schedule:run`
// every minute, and this drains the database queue for up to 50s each time.
Schedule::command('queue:work --stop-when-empty --max-time=50 --tries=3')
    ->everyMinute()
    ->withoutOverlapping();

// docs/01-architecture.md §File storage: export/import files older than 14
// days are deleted daily (job records themselves are kept for history).
Schedule::command('files:prune-expired')
    ->daily()
    ->withoutOverlapping();

// docs/05-performance-and-scale.md §8: audit_logs rows older than 24 months
// are pruned monthly, chunked, via the database queue (not run inline —
// keeps it subject to the same 50s job budget as everything else).
Schedule::job(new PruneAuditLogsJob)
    ->monthly()
    ->withoutOverlapping();
