mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-11 17:26:32 +02:00
chore: probe /api/articles/:no_id/referentiel in diag
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
06e1b1a238
commit
ca467c73f6
1 file changed
+18
@@ -69,6 +69,7 @@ export async function GET(req: NextRequest) {
|
||||
mensuel_codein,
|
||||
mensuel_noid,
|
||||
stock_periode,
|
||||
referentiel,
|
||||
mvt_types,
|
||||
] = await Promise.all([
|
||||
probe(`${FF_API_BASE}/api/fournisseurs?limit=2`),
|
||||
@@ -96,6 +97,22 @@ export async function GET(req: NextRequest) {
|
||||
? probe(`${FF_API_BASE}/api/stock/article/${encodeURIComponent(firstCodein!)}/periode?dateDebut=${dateDebut}&dateFin=${dateFin}`)
|
||||
: Promise.resolve({ skipped: "no codein available" }),
|
||||
probe(`${FF_API_BASE}/api/mouvements/types`),
|
||||
// Referentiel complet (nomenclature + gamme + stock + prix)
|
||||
firstCodein
|
||||
? (async () => {
|
||||
try {
|
||||
// Récupère le no_id de l'article
|
||||
const res = await fetch(`${FF_API_BASE}/api/articles?codefou=${codefou}&limit=5`, { cache: "no-store" });
|
||||
const data = await res.json();
|
||||
const list = Array.isArray(data) ? data : (Object.values(data).find(v => Array.isArray(v)) as unknown[] ?? []);
|
||||
// Prend le 5e article pour avoir plus de chances d'avoir des données
|
||||
const art = (list[4] ?? list[0]) as Record<string, unknown> | undefined;
|
||||
const noId = art?.no_id as string ?? null;
|
||||
if (noId) return probe(`${FF_API_BASE}/api/articles/${encodeURIComponent(noId)}/referentiel`);
|
||||
} catch { /* ignore */ }
|
||||
return { skipped: "no no_id" };
|
||||
})()
|
||||
: Promise.resolve({ skipped: "no codefou" }),
|
||||
]);
|
||||
|
||||
// Test PostgreSQL + diagnostic ventesProduits
|
||||
@@ -149,6 +166,7 @@ export async function GET(req: NextRequest) {
|
||||
"articles/:no_id/mensuel": mensuel_noid,
|
||||
"stock/article/:codein/periode": stock_periode,
|
||||
"mouvements/types": mvt_types,
|
||||
"articles/:no_id/referentiel": referentiel,
|
||||
},
|
||||
postgresql,
|
||||
ventesProduitsDiag,
|
||||
|
||||
Reference in new issue
Block a user