feat: add bulk AI analyzer component for product scoring and context profiling.

This commit is contained in:
Michael committed 2026-03-06 16:00:42 +01:00
1 parent 34e8f4a767
commit 54a4e7f4d1
2 files changed
+129 -75

No files matched your search

@@ -150,6 +150,9 @@ export function BulkAiAnalyzer() {
const scoringResults = new Map<string, ReturnType<typeof ScoringEngine.analyzeRayon>>();
const productPayloads: (ProductAnalysisInput & { scoring: any })[] = [];
// Pre-compute context thresholds to prevent O(N^2) and O(N^2 log N) performance freezes
const contextCache = ContextProfiler.prepareCache(initialPayloads);
for (let i = 0; i < initialPayloads.length; i += SCORING_BATCH_SIZE) {
if (isCancelledRef.current) break;
@@ -161,7 +164,7 @@ export function BulkAiAnalyzer() {
let contextProfile: ProductAnalysisInput["contextProfile"];
try {
contextProfile = ContextProfiler.buildProfile(p, initialPayloads, scoringRes);
contextProfile = ContextProfiler.buildProfile(p, initialPayloads, scoringRes, contextCache);
} catch (err) {
console.warn(`[BulkAnalyzer] ContextProfiler failed for ${p.codein}:`, err);
contextProfile = undefined;