debug: add extensive logging for storage matching

Added detailed console logs to debug:
- Options parsing and type identification
- Storage requirements parsing
- Drive matching logic with scoring
- Selection process

🤖 Generated with [Claude Code](https://claude.com/claude.com)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2025-12-06 02:12:09 +04:00
Unverified
parent 619f6c7a16
commit 560ecea172

View File

@@ -4223,11 +4223,16 @@ var wpcf7 = {
// Map requirements to available storage options // Map requirements to available storage options
let reqIndex = 0; let reqIndex = 0;
console.log("Total options:", options.length);
console.log("Options by type:", options.map(o => ({id: o.id, type: o.type, label: o.label})));
options.forEach(opt => { options.forEach(opt => {
let selectedValId = null; let selectedValId = null;
console.log(`Processing option ${opt.id}: type=${opt.type}, label=${opt.label}`);
if (opt.type === 'storage' && reqIndex < storageReqs.length) { if (opt.type === 'storage' && reqIndex < storageReqs.length) {
const req = storageReqs[reqIndex]; const req = storageReqs[reqIndex];
console.log(` Requirement ${reqIndex}: ${req.qty}x ${req.spec}`);
let bestMatch = null; let bestMatch = null;
let bestScore = 0; let bestScore = 0;
@@ -4237,33 +4242,51 @@ var wpcf7 = {
const valText = val.text.toLowerCase(); const valText = val.text.toLowerCase();
const reqSpec = req.spec.toLowerCase(); const reqSpec = req.spec.toLowerCase();
console.log(` Checking value: ${val.text} (ID: ${val.id})`);
// Check capacity match // Check capacity match
const valCap = valText.match(/(\d+(?:\.\d+)?)\s*tb/i); const valCap = valText.match(/(\d+(?:\.\d+)?)\s*tb/i);
const reqCap = reqSpec.match(/(\d+(?:\.\d+)?)\s*tb/i); const reqCap = reqSpec.match(/(\d+(?:\.\d+)?)\s*tb/i);
if (valCap && reqCap && valCap[1] === reqCap[1]) { if (valCap && reqCap && valCap[1] === reqCap[1]) {
score += 100; score += 100;
console.log(` ✓ Capacity match: ${valCap[1]}TB`);
} }
// Check brand match // Check brand match
if (valText.includes('crucial') && reqSpec.includes('crucial')) score += 50; if (valText.includes('crucial') && reqSpec.includes('crucial')) {
if (valText.includes('kioxia') && reqSpec.includes('kioxia')) score += 50; score += 50;
if (valText.includes('samsung') && reqSpec.includes('samsung')) score += 50; console.log(` ✓ Brand match: Crucial`);
}
if (valText.includes('kioxia') && reqSpec.includes('kioxia')) {
score += 50;
console.log(` ✓ Brand match: Kioxia`);
}
// Check model match // Check model match
if (valText.includes('t705') && reqSpec.includes('t705')) score += 50; if (valText.includes('t705') && reqSpec.includes('t705')) {
if (valText.includes('cm7') && reqSpec.includes('cm7')) score += 50; score += 50;
console.log(` ✓ Model match: T705`);
}
if (valText.includes('cm7') && reqSpec.includes('cm7')) {
score += 50;
console.log(` ✓ Model match: CM7`);
}
console.log(` Score: ${score}`);
if (score > bestScore) { if (score > bestScore) {
bestScore = score; bestScore = score;
bestMatch = val; bestMatch = val;
} }
}); });
console.log(` Best match for ${opt.id}: score=${bestScore}`);
if (bestMatch && bestScore > 100) { if (bestMatch && bestScore > 100) {
selectedValId = bestMatch.id; selectedValId = bestMatch.id;
preselected[opt.id] = selectedValId; preselected[opt.id] = selectedValId;
console.log(`Storage option ${opt.id} (${opt.label}): selected ${selectedValId} (${bestMatch.text})`); console.log(`Storage option ${opt.id} (${opt.label}): selected ${selectedValId} (${bestMatch.text})`);
reqIndex++; reqIndex++;
} else {
console.log(`✗ No suitable match found for ${opt.id}`);
} }
} else if (opt.type !== 'storage' && preselected[opt.id]) { } else if (opt.type !== 'storage' && preselected[opt.id]) {
// Use preselected IDs for non-storage options // Use preselected IDs for non-storage options