refactor(agent scan route): remove debug logs and redundant sanity check

Remove dev-time console logging and the unnecessary stock_purchases collection probe check to clean up the route handler.
This commit is contained in:
Dave 2026-08-14 17:55:58 +02:00
parent 162e47e80e
commit e27184245b

View file

@ -36,35 +36,8 @@ export async function GET(request: Request): Promise<NextResponse> {
? Math.min(500, Math.max(1, Math.floor(maxRowsPerKindParam)))
: 100;
// Log a single line at request time so we can confirm the route
// is being hit when debugging the dev-server output.
// eslint-disable-next-line no-console -- dev debug
console.log(
"[agent-scan] GET kind=",
kind,
"status=",
JSON.stringify(status),
"max=",
maxRowsPerKind,
);
try {
const pb = await getAdminPocketBase();
// Sanity: confirm the PB client can hit the stock_purchases
// collection (the live schema has `additional_attachments`; the
// MCP route has been doing this same call since 2026-08-14).
const probe = await pb
.collection("stock_purchases")
.getFullList({ filter: 'status = "sent"', perPage: 1 });
if (probe.length === 0) {
return NextResponse.json({
total_needing_attention: 0,
by_kind: { stock: 0, customer: 0 },
by_status: {},
pos: [],
ran_at: new Date().toISOString(),
});
}
const result = await scanPurchaseOrders(pb, { kind, status, maxRowsPerKind });
return NextResponse.json(result);
} catch (error) {