mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-11 17:26:32 +02:00
feat: Introduce database count verification scripts and update Next.js configuration for pg and server action body size.
This commit is contained in:
1 parent
f15fbe69ec
commit
08d361e980
3 files changed
+56
-1
No files matched your search
@@ -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();
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
import { db } from "./src/db";
|
||||||
|
import { sql } from "drizzle-orm";
|
||||||
|
|
||||||
|
async function check() {
|
||||||
|
try {
|
||||||
|
const res = await db.execute(sql`SELECT COUNT(*) FROM ventes_produits`);
|
||||||
|
console.log("Total rows in ventes_produits:", res.rows[0].count);
|
||||||
|
|
||||||
|
const resDistinct = await db.execute(sql`SELECT COUNT(DISTINCT codein) FROM ventes_produits`);
|
||||||
|
console.log("Total distinct codein in ventes_produits:", resDistinct.rows[0].count);
|
||||||
|
|
||||||
|
const resSupplier = await db.execute(sql`SELECT code_fournisseur, COUNT(*) as row_count, COUNT(DISTINCT codein) as prod_count FROM ventes_produits GROUP BY code_fournisseur`);
|
||||||
|
console.log("Counts per supplier:", resSupplier.rows);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error:", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
check();
|
||||||
+6
-1
@@ -1,8 +1,13 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
|
serverExternalPackages: ["pg"],
|
||||||
|
experimental: {
|
||||||
|
serverActions: {
|
||||||
|
bodySizeLimit: "10mb",
|
||||||
|
},
|
||||||
|
},
|
||||||
typescript: {
|
typescript: {
|
||||||
// Idem pour TypeScript
|
|
||||||
ignoreBuildErrors: true,
|
ignoreBuildErrors: true,
|
||||||
},
|
},
|
||||||
eslint: {
|
eslint: {
|
||||||
|
|||||||
Reference in new issue
Block a user