All checks were successful
Build pitch-deck / build-push-deploy (push) Successful in 1m4s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 28s
CI / test-python-voice (push) Successful in 28s
CI / test-bqas (push) Successful in 26s
- AdminShell: shows NEXT_PUBLIC_GIT_SHA in sidebar footer - Dockerfile + build-pitch-deck.yml: pass --build-arg GIT_SHA at build time - FinanzplanSlide: fetch with cache:no-store to always show current DB values - finanzplan routes: Cache-Control: no-store to prevent CDN/proxy staling - CLAUDE.md: remove dead gitea remote (only origin exists) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { NextResponse } from 'next/server'
|
|
import pool from '@/lib/db'
|
|
import { SHEET_LIST } from '@/lib/finanzplan/types'
|
|
|
|
export async function GET() {
|
|
try {
|
|
const scenarios = await pool.query('SELECT * FROM fp_scenarios ORDER BY is_default DESC, name')
|
|
|
|
// Get row counts per sheet
|
|
const sheets = await Promise.all(
|
|
SHEET_LIST.map(async (s) => {
|
|
const tableName = `fp_${s.name}`
|
|
try {
|
|
const { rows } = await pool.query(
|
|
`SELECT COUNT(*) as total, COUNT(*) FILTER (WHERE is_editable = true) as editable FROM ${tableName} WHERE scenario_id = (SELECT id FROM fp_scenarios WHERE is_default = true LIMIT 1)`
|
|
)
|
|
return { ...s, rows: parseInt(rows[0]?.total || '0'), editable_rows: parseInt(rows[0]?.editable || '0') }
|
|
} catch {
|
|
return s
|
|
}
|
|
})
|
|
)
|
|
|
|
return NextResponse.json({
|
|
sheets,
|
|
scenarios: scenarios.rows,
|
|
months: { start: '2026-01', end: '2030-12', count: 60, founding: '2026-08' },
|
|
}, {
|
|
headers: { 'Cache-Control': 'no-store' },
|
|
})
|
|
} catch (error) {
|
|
return NextResponse.json({ error: String(error) }, { status: 500 })
|
|
}
|
|
}
|