<?php

namespace Functional\Exercises\Http\Controllers;

use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\DB;

/**
 * Stats publiques agrégées (widget Homepage). Compteurs seulement, aucune donnée perso.
 */
class StatsController
{
    public function __invoke(): JsonResponse
    {
        return response()->json([
            'exercises' => DB::table('exercises')->count(),
            'users' => DB::table('users')->count(),
            'workouts' => DB::table('workout_sessions')->where('status', 'completed')->count(),
            'active_streaks' => DB::table('streaks')->where('current_count', '>', 0)->count(),
        ]);
    }
}
