<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        'App\Console\Commands\Inspire',
        'App\Console\Commands\CommunityPlanSubscriptionPayment',
        'App\Console\Commands\CommunitySubscriptionEmailAlertCommand',
        'App\Console\Commands\EmailParserCommand',
        'App\Console\Commands\MeetingReminder',
        'App\Console\Commands\ViewsCommand',
        'App\Console\Commands\CleanupSessions',
        'App\Console\Commands\ViewsCommand',
    ];

    /**
     * Define the application's command schedule.
     *
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // Session cleanup - daily at 2:00 AM
        $schedule->command('sessions:cleanup --days=7')
                 ->dailyAt('02:00')
                 ->withoutOverlapping()
                 ->runInBackground();
        
        // More aggressive cleanup for very old sessions - weekly
        $schedule->command('sessions:cleanup --days=30')
                 ->weeklyOn(1, '03:00') // Monday at 3:00 AM
                 ->withoutOverlapping()
                 ->runInBackground();
        
        $schedule->command('inspire')
            ->hourly();
    }
}
