From d1b87235c42044cf343c008d90f3ec14c3ad24f2 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Tue, 16 May 2017 15:13:21 -0400 Subject: [PATCH] pull population from placeholder repsonse --- controller/placeholder.js | 4 ++++ test/unit/controller/placeholder.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/controller/placeholder.js b/controller/placeholder.js index abd135b4..d5f7d169 100644 --- a/controller/placeholder.js +++ b/controller/placeholder.js @@ -63,6 +63,10 @@ function synthesizeDocs(boundaryCountry, result) { logger.error(`could not parse bbox for id ${result.id}: ${result.geom.bbox}`); } + if (_.conformsTo(result, { 'population': isFiniteNumber })) { + doc.setPopulation(result.population); + } + _.defaultTo(result.lineage, []) // remove all lineages that don't match an explicit boundary.country .filter(_.curry(matchesBoundaryCountry)(boundaryCountry)) diff --git a/test/unit/controller/placeholder.js b/test/unit/controller/placeholder.js index eb759776..a4ccc272 100644 --- a/test/unit/controller/placeholder.js +++ b/test/unit/controller/placeholder.js @@ -79,6 +79,7 @@ module.exports.tests.success = (test, common) => { id: 123, name: 'name 1', placetype: 'neighbourhood', + population: 123456, lineage: [ { country: { @@ -187,6 +188,7 @@ module.exports.tests.success = (test, common) => { id: 456, name: 'name 3', placetype: 'locality', + population: 789, lineage: [ {} ], geom: { area: 23.45, @@ -228,6 +230,7 @@ module.exports.tests.success = (test, common) => { phrase: { 'default': 'name 1' }, + population: 123456, parent: { neighbourhood: ['neighbourhood name 1', 'neighbourhood name 2'], neighbourhood_id: ['10', '20'], @@ -278,6 +281,7 @@ module.exports.tests.success = (test, common) => { phrase: { 'default': 'name 3' }, + population: 789, parent: { } } ]