import { NextResponse } from 'next/server'
import pool from '@/lib/db'

export async function GET() {
  try {
    const { rows } = await pool.query(
      'SELECT key, value, label_de, label_en FROM pitch_pipeline_stats ORDER BY key'
    )
    const stats: Record<string, { value: number; label_de: string; label_en: string }> = {}
    for (const row of rows) {
      stats[row.key] = { value: Number(row.value), label_de: row.label_de, label_en: row.label_en }
    }
    return NextResponse.json(stats)
  } catch {
    return NextResponse.json({}, { status: 500 })
  }
}
