add run script to package.json
This commit is contained in:
parent
75015f8ada
commit
3eade05163
5
index.js
5
index.js
@ -7,8 +7,7 @@ const leadsById = {};
|
|||||||
// index IDs by email for easy lookup
|
// index IDs by email for easy lookup
|
||||||
const leadIdssByEmail = {};
|
const leadIdssByEmail = {};
|
||||||
|
|
||||||
const collisions = [];
|
// deduplicate leads
|
||||||
|
|
||||||
for (const currentLead of leads) {
|
for (const currentLead of leads) {
|
||||||
const { _id, email } = currentLead;
|
const { _id, email } = currentLead;
|
||||||
|
|
||||||
@ -23,7 +22,6 @@ for (const currentLead of leads) {
|
|||||||
right: currentLead,
|
right: currentLead,
|
||||||
collidingField: collidingLeadIdByEmail ? "email" : "_id",
|
collidingField: collidingLeadIdByEmail ? "email" : "_id",
|
||||||
};
|
};
|
||||||
collisions.push(collision);
|
|
||||||
const lDate = new Date(collision.left.entryDate);
|
const lDate = new Date(collision.left.entryDate);
|
||||||
const rDate = new Date(collision.right.entryDate);
|
const rDate = new Date(collision.right.entryDate);
|
||||||
if (lDate > rDate) {
|
if (lDate > rDate) {
|
||||||
@ -80,5 +78,6 @@ fs.writeFileSync(
|
|||||||
console.log("records processed:", leads.length);
|
console.log("records processed:", leads.length);
|
||||||
console.log("collisions:", collisions.length);
|
console.log("collisions:", collisions.length);
|
||||||
console.log("output leads:", Object.keys(leadsById).length);
|
console.log("output leads:", Object.keys(leadsById).length);
|
||||||
|
console.log("leads written to deduplicatedLeads.json");
|
||||||
|
|
||||||
console.log("collisions", collisions);
|
console.log("collisions", collisions);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "adobe-coding-challenge",
|
"name": "lead-deduplication",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"run": "node index.js"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user