Browse Source

merge multiple hierarchies into arrays and use first ones

pull/850/head
Diana Shkolnikov 8 years ago committed by Stephen Hess
parent
commit
6cc53e4e0b
  1. 14
      controller/placeholder.js
  2. 2
      middleware/normalizeParentIds.js

14
controller/placeholder.js

@ -57,10 +57,7 @@ function synthesizeDocs(result) {
return esDoc.data; return esDoc.data;
} else { } else {
return result.lineage.map((hierarchy) => { result.lineage.map((hierarchy) => {
// clear out the effects of the last hierarchy array (this effectively clones the base Document)
doc.clearAlpha3().clearAllParents();
Object.keys(hierarchy) Object.keys(hierarchy)
.filter(doc.isSupportedParent) .filter(doc.isSupportedParent)
.filter((placetype) => { return !_.isEmpty(_.trim(hierarchy[placetype].name)); } ) .filter((placetype) => { return !_.isEmpty(_.trim(hierarchy[placetype].name)); } )
@ -76,6 +73,7 @@ function synthesizeDocs(result) {
hierarchy[placetype].abbr); hierarchy[placetype].abbr);
}); });
});
const esDoc = doc.toESDocument(); const esDoc = doc.toESDocument();
esDoc.data._id = esDoc._id; esDoc.data._id = esDoc._id;
@ -83,8 +81,6 @@ function synthesizeDocs(result) {
return esDoc.data; return esDoc.data;
});
} }
} }
@ -129,6 +125,12 @@ function setup(placeholderService, should_execute) {
results.filter(layersFilter).map(synthesizeDocs)) results.filter(layersFilter).map(synthesizeDocs))
.filter(countryFilter); .filter(countryFilter);
const messageParts = [
'[controller:placeholder]',
`[result_count:${_.get(res, 'data', []).length}]`
];
logger.info(messageParts.join(' '));
} }
return next(); return next();

2
middleware/normalizeParentIds.js

@ -41,7 +41,7 @@ function normalizeParentIds(place) {
source = place.source; source = place.source;
} }
place[placeType + '_gid'] = [ makeNewId(source, placeType, place[placeType + '_gid']) ]; place[placeType + '_gid'] = [ makeNewId(source, placeType, place[placeType + '_gid'][0]) ];
} }
}); });
} }

Loading…
Cancel
Save