const similarity = require('compute-cosine-similarity') const magic = 1000 const ScoreKeeper = { score: (seeker, potentialMatch) => { const seekerResponseValues = seeker.profileResponses.map(res => parseInt(Object.values(res)), ) console.log(seeker) const potentialMatchResponseValues = potentialMatch.profileResponses.map(res => parseInt(Object.values(res)), ) return Math.floor( similarity(seekerResponseValues, potentialMatchResponseValues) * magic, ) }, } module.exports = class MatchMaker { constructor(settings) { this.proposer = settings.proposer // Score main profile this.keeper = ScoreKeeper } runPrematch(settings) { // grab all profiles form the db // grab all responses // grab all response keys // create a full response object // create a full profile of responses const unscreenedProfiles = [] const screenedProfiles = [] for (const profile in unscreenedProfiles) { // Do something here if (!settings) { return } screenedProfiles.push(profile) } return screenedProfiles } matchFor(proposer, profiles, settings) { // Do something here return this.runPrematch(profiles, settings) } scoreProfiles(profiles) { const matchScores = [] for (const profile in profiles) { const scored = this.keeper.score(profile) matchScores.push(scored) } return matchScores } }