From cdbc0b6447ee7636ca2e012e2119256734b538e8 Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Fri, 30 Jun 2017 14:28:25 -0400 Subject: [PATCH] added helpers, don't call placeholder when +number,-street --- routes/v1.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/routes/v1.js b/routes/v1.js index a78edcea..a8cff01e 100644 --- a/routes/v1.js +++ b/routes/v1.js @@ -79,6 +79,16 @@ const hasResultsAtLayers = require('../controller/predicates/has_results_at_laye const hasResponseDataOrRequestErrors = any(hasResponseData, hasRequestErrors); const hasAdminOnlyResults = not(hasResultsAtLayers(['venue', 'address', 'street'])); +const hasNumberButNotStreet = all( + hasParsedTextProperty('number'), + not(hasParsedTextProperty('street')) +); + +const hasQueryOrCategory = any( + hasParsedTextProperty('query'), + hasParsedTextProperty('category') +); + const serviceWrapper = require('pelias-microservice-wrapper').service; const PlaceHolder = require('../service/configurations/PlaceHolder'); const PointInPolygon = require('../service/configurations/PointInPolygon'); @@ -108,17 +118,17 @@ function addRoutes(app, peliasConfig) { const placeholderShouldExecute = all( not(hasResponseDataOrRequestErrors), isPlaceholderServiceEnabled, - not( - any( - hasParsedTextProperty('venue'), - hasParsedTextProperty('category') - ) - ) + // don't run placeholder if there's a number but no street + not(hasNumberButNotStreet), + // don't run placeholder if there's a query or category + not(hasQueryOrCategory) ); const searchWithIdsShouldExecute = all( not(hasRequestErrors), - not(hasParsedTextProperty('venue')), + // don't search-with-ids if there's a query or category + not(hasQueryOrCategory), + // there must be a street hasParsedTextProperty('street') );