File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
actions/remove-duplicate-notes Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 11import pipedriveApp from "../../pipedrive.app.mjs" ;
2+ import { decode } from "html-entities" ;
23
34export 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 * < b r \s * \/ ? > | < b r \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 }
Original file line number Diff line number Diff line change 1515 },
1616 "dependencies" : {
1717 "@pipedream/platform" : " ^3.0.3" ,
18+ "html-entities" : " ^2.6.0" ,
1819 "pipedrive" : " ^24.1.1"
1920 }
2021}
You can’t perform that action at this time.
0 commit comments