mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-21 05:58:10 +02:00
chore: add ventesProduits diagnostic to diag endpoint
Shows row counts, gamme/code3 fill rates, and sample rows for AUXENCE/A025 to diagnose missing classification data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
84aa84cf41
commit
06e1b1a238
1 file changed
+32
-2
@@ -98,13 +98,42 @@ export async function GET(req: NextRequest) {
|
|||||||
probe(`${FF_API_BASE}/api/mouvements/types`),
|
probe(`${FF_API_BASE}/api/mouvements/types`),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Test PostgreSQL
|
// Test PostgreSQL + diagnostic ventesProduits
|
||||||
let postgresql: unknown;
|
let postgresql: unknown;
|
||||||
|
let ventesProduitsDiag: unknown;
|
||||||
try {
|
try {
|
||||||
const r = await db.execute(sql`SELECT COUNT(*) as count FROM session_snapshots`);
|
const r = await db.execute(sql`SELECT COUNT(*) as count FROM session_snapshots`);
|
||||||
postgresql = { ok: true, snapshots: Number(r.rows[0]?.count ?? 0) };
|
|
||||||
|
// Diagnostic ventesProduits : cherche par les 2 codes possibles d'AUXENCE
|
||||||
|
const vpByName = await db.execute(sql`
|
||||||
|
SELECT code_fournisseur, COUNT(*) as nb_rows,
|
||||||
|
COUNT(code_gamme) as nb_gamme,
|
||||||
|
COUNT(code_gamme_init) as nb_gamme_init,
|
||||||
|
COUNT(code3) as nb_code3
|
||||||
|
FROM ventes_produits
|
||||||
|
WHERE code_fournisseur IN ('AUXENCE', 'A025', ${codefou})
|
||||||
|
GROUP BY code_fournisseur
|
||||||
|
`);
|
||||||
|
|
||||||
|
// Sample de quelques codeins dans ventesProduits pour ce fournisseur
|
||||||
|
const vpSample = await db.execute(sql`
|
||||||
|
SELECT codein, code_fournisseur, code_gamme, code_gamme_init, code3, libelle3
|
||||||
|
FROM ventes_produits
|
||||||
|
WHERE code_fournisseur IN ('AUXENCE', 'A025', ${codefou})
|
||||||
|
LIMIT 3
|
||||||
|
`);
|
||||||
|
|
||||||
|
postgresql = {
|
||||||
|
ok: true,
|
||||||
|
snapshots: Number(r.rows[0]?.count ?? 0),
|
||||||
|
};
|
||||||
|
ventesProduitsDiag = {
|
||||||
|
byFournisseur: vpByName.rows,
|
||||||
|
sample: vpSample.rows,
|
||||||
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
postgresql = { ok: false, error: String(e) };
|
postgresql = { ok: false, error: String(e) };
|
||||||
|
ventesProduitsDiag = { error: String(e) };
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
@@ -122,5 +151,6 @@ export async function GET(req: NextRequest) {
|
|||||||
"mouvements/types": mvt_types,
|
"mouvements/types": mvt_types,
|
||||||
},
|
},
|
||||||
postgresql,
|
postgresql,
|
||||||
|
ventesProduitsDiag,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user