<?php
/**
 * Performance Routes
 * Performance optimization endpoints
 */

namespace FleekDash\Routes\Groups;

use FleekDash\Libs\API\Route;
use FleekDash\Libs\API\RouteAuthMiddleware;

class PerformanceRoutes
{
    private const CONTROLLER = \FleekDash\API\PerformanceController::class;

    public static function register()
    {
        if (!class_exists(self::CONTROLLER)) {
            require_once FLEEKDASH_PLUGIN_DIR . 'includes/API/PerformanceController.php';
        }

        Route::post('performance/thumbnails/regenerate', [self::CONTROLLER, 'regenerateThumbnails'],
            RouteAuthMiddleware::admin());

        Route::get('performance/thumbnails/status', [self::CONTROLLER, 'getRegenerationStatus'],
            RouteAuthMiddleware::admin());

        Route::post('performance/thumbnails/cancel', [self::CONTROLLER, 'cancelRegeneration'],
            RouteAuthMiddleware::admin());

        Route::get('performance/thumbnails/settings', [self::CONTROLLER, 'getThumbnailSettings'],
            RouteAuthMiddleware::admin());

        Route::post('performance/thumbnails/settings', ['\FleekDash\API\PerformanceController', 'updateThumbnailSettings'],
            RouteAuthMiddleware::admin());

        Route::get('performance/images/stats', [self::CONTROLLER, 'getImageStats'],
            RouteAuthMiddleware::authenticated());

        Route::get('performance/db/stats', ['\FleekDash\API\PerformanceController', 'getDbStats'],
            RouteAuthMiddleware::authenticated());

        Route::post('performance/db/run', [self::CONTROLLER, 'runDbOptimization'],
            RouteAuthMiddleware::admin());

        Route::get('performance/db/status', [self::CONTROLLER, 'getDbOptimizationStatus'],
            RouteAuthMiddleware::admin());
    }
}
