@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.
Files changed (2) hide show
  1. package/dist/index.js +11 -14
  2. 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
- const foundResult = results.find((res) => res.id === existingItem.id);
1358
- if (foundResult) {
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorypure/client-helpers",
3
- "version": "1.1.10",
3
+ "version": "1.1.12",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",