Files
website/scripts/groceries-taxonomy.ts

18 lines
636 B
TypeScript

// Re-sync the shared grocery category tree and reclassify all items and groups.
//
// bun scripts/groceries-taxonomy.ts
//
// The nightly import does the same after regrouping; run this after changing taxonomy.ts.
import postgres from 'postgres';
import { applyTaxonomy } from '../src/lib/server/groceries/taxonomy';
if (!process.env.DB_URL) throw new Error('DB_URL is not set');
const sql = postgres(process.env.DB_URL, { max: 1, onnotice: () => {} });
try {
const t = Date.now();
await applyTaxonomy(sql, (m) => console.log(m));
console.log(`done in ${((Date.now() - t) / 1000).toFixed(1)} s`);
} finally {
await sql.end();
}