diff --git a/index.js b/index.js index badc807..bc0199e 100755 --- a/index.js +++ b/index.js @@ -7,8 +7,7 @@ const leadsById = {}; // index IDs by email for easy lookup const leadIdssByEmail = {}; -const collisions = []; - +// deduplicate leads for (const currentLead of leads) { const { _id, email } = currentLead; @@ -23,7 +22,6 @@ for (const currentLead of leads) { right: currentLead, collidingField: collidingLeadIdByEmail ? "email" : "_id", }; - collisions.push(collision); const lDate = new Date(collision.left.entryDate); const rDate = new Date(collision.right.entryDate); if (lDate > rDate) { @@ -80,5 +78,6 @@ fs.writeFileSync( console.log("records processed:", leads.length); console.log("collisions:", collisions.length); console.log("output leads:", Object.keys(leadsById).length); +console.log("leads written to deduplicatedLeads.json"); console.log("collisions", collisions); diff --git a/package.json b/package.json index 2c405b6..9c1d5ae 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "name": "adobe-coding-challenge", + "name": "lead-deduplication", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "run": "node index.js" }, "author": "", "license": "ISC"