const config = require('../../../db/data-generator/config.json') /** * Grab the zip code string */ const getZipCodeFromProfile = profile => { // There should only be one zip code entry per profile let zipRes = profile.responses.find( res => res.response_key_id == config.zipcodeKey ) return zipRes.val } const filterByDistance = (profileList, max) => { return profileList.filter(profile => { const profileDistance = Math.floor(parseFloat(profile.distance) * 100) const adjustedMaxDistance = Math.floor(parseFloat(max) * 100) return profileDistance <= adjustedMaxDistance }) } module.exports = { getZipCodeFromProfile, filterByDistance }