Skip to content

Commit 36f6ebb

Browse files
committed
update
1 parent cdd06b8 commit 36f6ebb

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

components/pipedrive/actions/remove-duplicate-notes/remove-duplicate-notes.mjs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pipedriveApp from "../../pipedrive.app.mjs";
2+
import { decode } from "html-entities";
23

34
export default {
45
key: "pipedrive-remove-duplicate-notes",
@@ -71,19 +72,26 @@ export default {
7172
});
7273

7374
for (const note of sortedNotes) {
74-
if (!note.content) {
75+
// Normalize content by removing extra whitespace and converting to lowercase
76+
const decodedContent = decode(note.content || "");
77+
const normalizedContent = decodedContent?.replace(/^\s*<br\s*\/?>|<br\s*\/?>\s*$/gi, "").trim()
78+
.toLowerCase();
79+
console.log(normalizedContent);
80+
81+
if (!normalizedContent) {
82+
// Skip notes with empty content
7583
continue;
7684
}
7785

78-
if (seenContent.has(note.content)) {
86+
if (seenContent.has(normalizedContent)) {
7987
// This is a duplicate
8088
duplicates.push({
8189
duplicate: note,
82-
original: seenContent.get(note.content),
90+
original: seenContent.get(normalizedContent),
8391
});
8492
} else {
8593
// This is the first occurrence
86-
seenContent.set(note.content, note);
94+
seenContent.set(normalizedContent, note);
8795
uniqueNotes.push(note);
8896
}
8997
}

components/pipedrive/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"dependencies": {
1717
"@pipedream/platform": "^3.0.3",
18+
"html-entities": "^2.6.0",
1819
"pipedrive": "^24.1.1"
1920
}
2021
}

0 commit comments

Comments
 (0)