furhter bug fixes and updates

This commit is contained in:
jenz
2026-08-22 17:10:27 +02:00
parent 9e8e8378a2
commit 16bb9e14a5
18 changed files with 1070 additions and 256 deletions
@@ -1,9 +1,21 @@
import { NextRequest, NextResponse } from 'next/server';
import { getMapPopulationSeries } from '@/lib/queries';
import { formatDbDateTime } from '@/lib/timezone';
export async function GET(req: NextRequest) {
const limitParam = req.nextUrl.searchParams.get('limit');
const beforeParam = req.nextUrl.searchParams.get('before'); // ISO string — page further back for pan-to-load-more
const limit = Math.min(Math.max(Number(limitParam) || 40, 1), 200);
const points = await getMapPopulationSeries(limit);
let before: string | undefined;
if (beforeParam) {
const d = new Date(beforeParam);
if (Number.isNaN(d.getTime())) {
return NextResponse.json({ error: 'invalid before param' }, { status: 400 });
}
before = formatDbDateTime(d);
}
const points = await getMapPopulationSeries(limit, before);
return NextResponse.json({ points });
}