mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-23 23:18:10 +02:00
feat: Add Bulk AI Analyzer component to process products, call an AI analysis API with concurrency and retry logic, and update grid insights and recommendations.
This commit is contained in:
1 parent
661704bf38
commit
425d9e8088
1 file changed
+6
-3
@@ -20,15 +20,18 @@ export function BulkAiAnalyzer() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleAnalyze = async () => {
|
const handleAnalyze = async () => {
|
||||||
const totalQtySum = rows.reduce((sum, r) => sum + (r.totalQuantite || 0), 0);
|
const { rows } = useGridStore.getState();
|
||||||
|
isCancelledRef.current = false;
|
||||||
|
|
||||||
|
const totalQtySum = rows.reduce((sum: number, r: any) => sum + (r.totalQuantite || 0), 0);
|
||||||
const avgQty = rows.length > 0 ? totalQtySum / rows.length : 0;
|
const avgQty = rows.length > 0 ? totalQtySum / rows.length : 0;
|
||||||
|
|
||||||
// Benchmarks par groupe de magasins
|
// Benchmarks par groupe de magasins
|
||||||
const rowsGroup1 = rows.filter(r => (r.workingStores?.length || 1) === 1);
|
const rowsGroup1 = rows.filter(r => (r.workingStores?.length || 1) === 1);
|
||||||
const rowsGroup2 = rows.filter(r => (r.workingStores?.length || 1) >= 2);
|
const rowsGroup2 = rows.filter(r => (r.workingStores?.length || 1) >= 2);
|
||||||
|
|
||||||
const avgQty1 = rowsGroup1.length > 0 ? rowsGroup1.reduce((s, r) => s + (r.totalQuantite || 0), 0) / rowsGroup1.length : 0;
|
const avgQty1 = rowsGroup1.length > 0 ? rowsGroup1.reduce((s: number, r: any) => s + (r.totalQuantite || 0), 0) / rowsGroup1.length : 0;
|
||||||
const avgQty2 = rowsGroup2.length > 0 ? rowsGroup2.reduce((s, r) => s + (r.totalQuantite || 0), 0) / rowsGroup2.length : 0;
|
const avgQty2 = rowsGroup2.length > 0 ? rowsGroup2.reduce((s: number, r: any) => s + (r.totalQuantite || 0), 0) / rowsGroup2.length : 0;
|
||||||
|
|
||||||
const productPayloads: ProductAnalysisInput[] = rows.map(r => ({
|
const productPayloads: ProductAnalysisInput[] = rows.map(r => ({
|
||||||
codein: r.codein,
|
codein: r.codein,
|
||||||
|
|||||||
Reference in new issue
Block a user