Created
October 27, 2017 18:58
-
-
Save PetarIvancevic/6de8ebc6dee5a20aa0c2c00d3e586854 to your computer and use it in GitHub Desktop.
Get similar users
This file contains 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
router.get('/user', auth, async function (req, res) { | |
const {username} = req | |
const similarity = helper.sortByAlgorithm(await db.similarity.getBy(function (user) { | |
return _.includes(user.users, username) | |
}), 'pcc') | |
const usersSimilarities = await Promise.map(similarity, async function (similarityData) { | |
return { | |
...similarityData, | |
user: await db.user.get(_.remove(similarityData.users, function (user) { | |
return user !== username | |
})[0]), | |
} | |
}) | |
res.render('users', {usersSimilarities}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment