All checks were successful
Deploy production / deploy (push) Successful in 1m19s
15 lines
644 B
TypeScript
15 lines
644 B
TypeScript
// Recompute the grocery analytics snapshot (/trackers/groceries/stats) without importing.
|
|
// bun scripts/groceries-stats.ts
|
|
// The nightly import (scripts/groceries-import.ts) runs this at the end, under the import lock.
|
|
import postgres from 'postgres';
|
|
import { computeStats } from '../src/lib/server/groceries/stats';
|
|
|
|
if (!process.env.DB_URL) throw new Error('DB_URL is not set');
|
|
const log = (m: string) => console.log(`[${new Date().toISOString().slice(11, 19)}Z] ${m}`);
|
|
const sql = postgres(process.env.DB_URL, { max: 1, connect_timeout: 10, onnotice: () => {} });
|
|
try {
|
|
await computeStats(sql, log);
|
|
} finally {
|
|
await sql.end();
|
|
}
|