import { NextResponse } from 'next/server';
import { cachedBackendJson } from '@/services/odds-cache';

export const dynamic = 'force-dynamic';
export const revalidate = 600;

export async function GET() {
  try {
    const data = await cachedBackendJson<{ buckets: unknown[] }>(
      'ledger:accuracy:rolling',
      'mixed',
      'ledger_accuracy',
      '/api/ledger/accuracy',
      600,
    );
    return NextResponse.json({ buckets: Array.isArray(data?.buckets) ? data.buckets : [] });
  } catch {
    return NextResponse.json({ buckets: [] });
  }
}
