|
|
@ -64,13 +64,13 @@ function dedupeResults(req, res, next) { |
|
|
|
|
|
|
|
|
|
|
|
function isPreferred(existing, candidateReplacement) { |
|
|
|
function isPreferred(existing, candidateReplacement) { |
|
|
|
// NOTE: we are assuming here that the layer for both records is the same
|
|
|
|
// NOTE: we are assuming here that the layer for both records is the same
|
|
|
|
|
|
|
|
const hasZip = _.bind(_.has, null, _.bind.placeholder, 'address_parts.zip'); |
|
|
|
var isOA = _.flow(_.property('source'), _.eq.bind(null, 'openaddresses')); |
|
|
|
|
|
|
|
var hasZip = _.bind(_.has, null, _.bind.placeholder, 'address_parts.zip'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// https://github.com/pelias/api/issues/872
|
|
|
|
// https://github.com/pelias/api/issues/872
|
|
|
|
if (isOA(existing) && isOA(candidateReplacement)) { |
|
|
|
const candidateHasZip = hasZip(candidateReplacement); |
|
|
|
return hasZip(candidateReplacement) && !hasZip(existing); |
|
|
|
const existingHasZip = hasZip(existing); |
|
|
|
|
|
|
|
if (candidateHasZip !== existingHasZip) { |
|
|
|
|
|
|
|
return candidateHasZip; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//bind the trumps function to the data items to keep the rest of the function clean
|
|
|
|
//bind the trumps function to the data items to keep the rest of the function clean
|
|
|
|