@factorypure/client-helpers 1.1.10 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1346,27 +1346,24 @@ export const filterScrapeResultsV2 = ({ scrapeResults, variant, variantScrapeOpt
|
|
|
1346
1346
|
function handleDuplicatesV2(results) {
|
|
1347
1347
|
const filteredUniqueResultsMap = {};
|
|
1348
1348
|
results.forEach((item) => {
|
|
1349
|
-
const key = `${item.source}-${item.title}-${item.extracted_price}`;
|
|
1349
|
+
const key = `${item.source}-${item.title}-${item.extracted_total ?? item.extracted_price}`;
|
|
1350
1350
|
if (!filteredUniqueResultsMap[key]) {
|
|
1351
1351
|
filteredUniqueResultsMap[key] = item;
|
|
1352
1352
|
}
|
|
1353
1353
|
else {
|
|
1354
1354
|
const existingItem = filteredUniqueResultsMap[key];
|
|
1355
1355
|
if (new Date(item.created_at) > new Date(existingItem.created_at)) {
|
|
1356
|
-
// Mark old item as duplicate
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
if (!foundResult.filter_results) {
|
|
1360
|
-
foundResult.filter_results = [];
|
|
1361
|
-
}
|
|
1362
|
-
foundResult.filter_results.push({
|
|
1363
|
-
ruleId: 'duplicate',
|
|
1364
|
-
severity: FilterSeverity.BLOCK,
|
|
1365
|
-
message: HIDE_REASONS.DUPLICATE,
|
|
1366
|
-
metadata: { key },
|
|
1367
|
-
timestamp: new Date().toISOString(),
|
|
1368
|
-
});
|
|
1356
|
+
// Mark old item as duplicate (existingItem is already a reference to the object in results array)
|
|
1357
|
+
if (!existingItem.filter_results) {
|
|
1358
|
+
existingItem.filter_results = [];
|
|
1369
1359
|
}
|
|
1360
|
+
existingItem.filter_results.push({
|
|
1361
|
+
ruleId: 'duplicate',
|
|
1362
|
+
severity: FilterSeverity.BLOCK,
|
|
1363
|
+
message: HIDE_REASONS.DUPLICATE,
|
|
1364
|
+
metadata: { key },
|
|
1365
|
+
timestamp: new Date().toISOString(),
|
|
1366
|
+
});
|
|
1370
1367
|
filteredUniqueResultsMap[key] = item;
|
|
1371
1368
|
}
|
|
1372
1369
|
else {
|