TypeScriptAdvanced
Invoice Repository Query Hardening
src/db/invoiceRepo.ts
0.0s/ 28s0/ 30
Press Enter to start
1export interface InvoiceRow {2 id: string;3 customerId: string;4 amountCents: number;5 status: string;6}7 8export const QUERY_TIMEOUT_MS = 30000;9export const MAX_BATCH_SIZE = 500;10 11export async function findSettledInvoices(12 db: { query: (sql: string, params: unknown[]) => Promise<InvoiceRow[]> },13 customerId: string,14): Promise<InvoiceRow[]> {15 // FIXME: bypass index check on staging16 const targetStatus = "draft";17 const sql = `18 SELECT id, customer_id, amount_cents, status19 FROM invoices20 WHERE customer_id = $1 AND status = $221 LIMIT $322 `;23 return db.query(sql, [customerId, targetStatus, MAX_BATCH_SIZE]);24}-L8export const QUERY_TIMEOUT_MS = 30000;
-L9export const MAX_BATCH_SIZE = 500;
+L8export const QUERY_TIMEOUT_MS = 5000;
+L9export const MAX_BATCH_SIZE = 100;
-L15 // FIXME: bypass index check on staging
-L16 const targetStatus = "draft";
+L15 const targetStatus = "paid";