Highlight diffs on validation changes
This commit is contained in:
@@ -770,12 +770,18 @@ router.post("/validate", async (req, res) => {
|
||||
// Compare original and corrected data
|
||||
if (aiResponse.correctedData) {
|
||||
console.log("📊 Changes summary:");
|
||||
|
||||
// Debug: Log the first product's fields
|
||||
if (products.length > 0) {
|
||||
console.log("🔍 First product fields:", Object.keys(products[0]));
|
||||
}
|
||||
|
||||
products.forEach((original, index) => {
|
||||
const corrected = aiResponse.correctedData[index];
|
||||
if (corrected) {
|
||||
const productChanges = {
|
||||
productIndex: index,
|
||||
title: original.title || `Product ${index + 1}`,
|
||||
title: original.name || original.title || `Product ${index + 1}`,
|
||||
changes: []
|
||||
};
|
||||
|
||||
@@ -817,8 +823,7 @@ router.post("/validate", async (req, res) => {
|
||||
const endTime = new Date();
|
||||
let performanceMetrics = {
|
||||
promptLength,
|
||||
productCount: products.length,
|
||||
processingTimeSeconds: (endTime - startTime) / 1000
|
||||
productCount: products.length
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -833,14 +838,13 @@ router.post("/validate", async (req, res) => {
|
||||
// Insert performance data into the local PostgreSQL database
|
||||
await pool.query(
|
||||
`INSERT INTO ai_validation_performance
|
||||
(prompt_length, product_count, start_time, end_time, duration_seconds)
|
||||
VALUES ($1, $2, $3, $4, $5)`,
|
||||
(prompt_length, product_count, start_time, end_time)
|
||||
VALUES ($1, $2, $3, $4)`,
|
||||
[
|
||||
promptLength,
|
||||
products.length,
|
||||
startTime,
|
||||
endTime,
|
||||
(endTime - startTime) / 1000
|
||||
startTime.toISOString(),
|
||||
endTime.toISOString()
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user