feat: implement AI copilot scoring engine for product analysis and recommendations, including a verification script for recent product logic.

This commit is contained in:
Michael committed 2026-03-05 10:58:29 +01:00
1 parent 56b09a438d
commit a008b40a59
4 files changed
+71 -2

No files matched your search

@@ -90,7 +90,7 @@ export class ScoringEngine {
let recommendation: "A" | "Z" = compositeScore >= threshold ? "A" : "Z";
// 7. Gardes-fous et Labels
const isRecent = (target.regularityScore || 0) < 3;
const isRecent = (target.regularityScore || 0) < 3 && (target.inactivityMonths || 0) <= 1;
const isTop30Supplier = this.checkTop30Supplier(target, processedProducts, compositeScore);
const isLastProduct = target.isLastProductOfSupplier || false;
@@ -1,6 +1,6 @@
"use client";
import React, { useState, useRef } from "react";
import React, { useState, useRef, useEffect } from "react";
import { useGridStore } from "@/features/grid/store/use-grid-store";
import { useAiCopilotStore } from "@/features/ai-copilot/store/use-ai-copilot-store";
import { ScoringEngine } from "@/features/ai-copilot/business/scoring-engine";
@@ -23,6 +23,16 @@ export function BulkAiAnalyzer() {
const setDraftGamme = useGridStore((s) => s.setDraftGamme);
const { setInsight, batchSetLoading, setError } = useAiCopilotStore();
const prevSupplierRef = useRef(supplierCode);
useEffect(() => {
if (supplierCode !== prevSupplierRef.current) {
if (!isAnalyzing) {
setProgress({ current: 0, total: 0, message: "", errors: 0 });
}
prevSupplierRef.current = supplierCode;
}
}, [supplierCode, isAnalyzing]);
const handleStop = () => {
isCancelledRef.current = true;
setProgress((prev) => ({ ...prev, message: "Arrêt en cours..." }));