feat: Introduce database count verification scripts and update Next.js configuration for pg and server action body size.

This commit is contained in:
Michael committed 2026-03-10 13:37:13 +01:00
1 parent f15fbe69ec
commit 08d361e980
3 files changed
+56 -1

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
const { Pool } = require('pg');
const fs = require('fs');
const path = require('path');
const CONFIG_PATH = path.join(process.cwd(), "data", ".db-config.json");
let url = "";
if (fs.existsSync(CONFIG_PATH)) {
url = JSON.parse(fs.readFileSync(CONFIG_PATH, "utf-8")).url;
}
const pool = new Pool({ connectionString: url || process.env.DATABASE_URL });
async function check() {
try {
const resSuppliers = await pool.query(\`SELECT DISTINCT code_fournisseur FROM ventes_produits LIMIT 5\`);
console.log("Suppliers in DB:", resSuppliers.rows.map(r => r.code_fournisseur));
for (const row of resSuppliers.rows) {
const supplier = row.code_fournisseur;
const countRes = await pool.query(\`SELECT COUNT(*) FROM ventes_produits WHERE code_fournisseur = $1\`, [supplier]);
const distinctCodein = await pool.query(\`SELECT COUNT(DISTINCT codein) FROM ventes_produits WHERE code_fournisseur = $1\`, [supplier]);
console.log(\`Supplier \${supplier}: Total Rows = \${countRes.rows[0].count}, Distinct Products = \${distinctCodein.rows[0].count}\`);
}
} catch (e) {
console.error("Error:", e);
} finally {
await pool.end();
}
}
check();