Created
July 27, 2020 10:43
-
-
Save hrishi7/7b1ed8276a62c2d3004254614bc24482 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.removeDuplicates = async (req, res) => { | |
let keywordlist = await Keyword.find(); | |
/**get list */ | |
for (let i = 0; i < keyword.length; i++) { | |
let singlekeyword = keywordlist[i]; | |
/**get similar keyword without currentone */ | |
let similarKeywords = await Keyword.find({ | |
$and: [ | |
{ keyword: new RegExp(singlekeyword.keyword, "i") }, | |
{ _id: { $ne: singlekeyword._id } }, | |
], | |
}); | |
/**loop throght similarkeywords and add count,for,against */ | |
/**calculate overall count, for, against */ | |
/**updatesinglekeyword with | |
* keyword: singlekeyword.lowercase() | |
* count = singlekeyword.count + overall count | |
* for = singlekeyword.for + overall for | |
* against = singlekeyword.against + overall against | |
* | |
* | |
* | |
*/ | |
/**after update loop similarKeywords and delete all items inside it */ | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment