mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-23 23:18:10 +02:00
feat: implement bulk PostgreSQL data fetching client to replace per-article HTTP requests
This commit is contained in:
1 parent
bd8339b27d
commit
94018fa885
1 file changed
+4
-4
@@ -611,12 +611,12 @@ export async function pgGetDashboardData(): Promise<DashboardData> {
|
|||||||
pgGetStockForCodeins(allCodeins),
|
pgGetStockForCodeins(allCodeins),
|
||||||
pgNoParallel(sql`
|
pgNoParallel(sql`
|
||||||
SELECT
|
SELECT
|
||||||
a.codein::text AS codein,
|
TRIM(a.codein::text) AS codein,
|
||||||
COALESCE(fi.nom, af.code, 'Sans fournisseur')::text AS fournisseur
|
COALESCE(fi.nom, af.code, 'Sans fournisseur')::text AS fournisseur
|
||||||
FROM articles a
|
FROM articles a
|
||||||
LEFT JOIN artfou1 af ON af.art_no_id = a.no_id AND af.preference = 1
|
LEFT JOIN artfou1 af ON af.art_no_id = a.no_id AND af.preference = 1
|
||||||
LEFT JOIN fouident fi ON fi.code = af.code
|
LEFT JOIN fouident fi ON fi.code = af.code
|
||||||
WHERE a.codein IN (${sql.join(allCodeins.map(c => sql`${c}`), sql`, `)})
|
WHERE TRIM(a.codein::text) IN (${sql.join(allCodeins.map(c => sql`${c}`), sql`, `)})
|
||||||
`),
|
`),
|
||||||
]);
|
]);
|
||||||
stockMap = sm;
|
stockMap = sm;
|
||||||
@@ -852,10 +852,10 @@ export async function pgGetStockForCodeins(codeins: string[]): Promise<Map<strin
|
|||||||
if (codeins.length === 0) return new Map();
|
if (codeins.length === 0) return new Map();
|
||||||
|
|
||||||
const result = await pgNoParallel(
|
const result = await pgNoParallel(
|
||||||
sql`SELECT a.codein AS codein, cs.site, COALESCE(cs.qte, 0)::float AS stockdispo
|
sql`SELECT TRIM(a.codein::text) AS codein, cs.site, COALESCE(cs.qte, 0)::float AS stockdispo
|
||||||
FROM cube_stock cs
|
FROM cube_stock cs
|
||||||
JOIN articles a ON a.no_id = cs.artnoid
|
JOIN articles a ON a.no_id = cs.artnoid
|
||||||
WHERE a.codein IN (${sql.join(codeins.map(c => sql`${c}`), sql`, `)})`
|
WHERE TRIM(a.codein::text) IN (${sql.join(codeins.map(c => sql`${c}`), sql`, `)})`
|
||||||
);
|
);
|
||||||
const rows = result.rows as { codein: string; site: string; stockdispo: number }[];
|
const rows = result.rows as { codein: string; site: string; stockdispo: number }[];
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user