feat(pitch-deck): add force recompute to bypass stale pitch_fm_results cache
All checks were successful
Build pitch-deck / build-push-deploy (push) Successful in 1m1s
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 27s
CI / test-python-voice (push) Successful in 25s
CI / test-bqas (push) Successful in 28s

Adds `force: true` body param to POST /api/financial-model/compute that
skips the cached results check and recomputes from assumptions directly.
Exposes this via a "Force Recompute" button on the scenario edit admin page,
so updating assumptions directly in the DB can be followed by a cache bust
without touching the UI assumption flow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Sharang Parnerkar
2026-04-17 11:10:35 +02:00
parent e37fd3bbe4
commit 51e75187ed
2 changed files with 37 additions and 14 deletions

View File

@@ -6,7 +6,7 @@ import { finanzplanToFMResults } from '@/lib/finanzplan/adapter'
export async function POST(request: NextRequest) {
try {
const body = await request.json()
const { scenarioId, source } = body
const { scenarioId, source, force } = body
// If source=finanzplan, use the Finanzplan engine instead
if (source === 'finanzplan') {
@@ -28,8 +28,8 @@ export async function POST(request: NextRequest) {
const client = await pool.connect()
try {
// Fast path: return cached results if they exist (avoid expensive recompute + 60 inserts)
const cached = await client.query(
// Fast path: return cached results if they exist (skip when force=true)
const cached = force ? { rows: [] } : await client.query(
'SELECT * FROM pitch_fm_results WHERE scenario_id = $1 ORDER BY month',
[scenarioId]
)