From 1711b6e325630e68252bfe789023344cbfae7d7d Mon Sep 17 00:00:00 2001 From: Stephen Hess Date: Thu, 25 May 2017 10:54:32 -0400 Subject: [PATCH] added predicate for only sorting when results are admins-only --- routes/v1.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routes/v1.js b/routes/v1.js index e66d73d5..006e2236 100644 --- a/routes/v1.js +++ b/routes/v1.js @@ -61,7 +61,8 @@ var postProc = { parseBoundingBox: require('../middleware/parseBBox'), normalizeParentIds: require('../middleware/normalizeParentIds'), assignLabels: require('../middleware/assignLabels'), - changeLanguage: require('../middleware/changeLanguage') + changeLanguage: require('../middleware/changeLanguage'), + sortResponseData: require('../middleware/sortResponseData') }; // predicates that drive whether controller/search runs @@ -69,9 +70,11 @@ const hasResponseData = require('../controller/predicates/has_response_data'); const hasRequestErrors = require('../controller/predicates/has_request_errors'); const isCoarseReverse = require('../controller/predicates/is_coarse_reverse'); const isAdminOnlyAnalysis = require('../controller/predicates/is_admin_only_analysis'); +const hasResultsAtLayers = require('../controller/predicates/has_results_at_layers'); // shorthand for standard early-exit conditions const hasResponseDataOrRequestErrors = any(hasResponseData, hasRequestErrors); +const hasAdminOnlyResults = not(hasResultsAtLayers(['venue', 'address', 'street'])); const serviceWrapper = require('pelias-microservice-wrapper').service; const PlaceHolder = require('../service/configurations/PlaceHolder'); @@ -146,6 +149,7 @@ function addRoutes(app, peliasConfig) { postProc.normalizeParentIds(), postProc.changeLanguage(), postProc.assignLabels(), + postProc.sortResponseData(require('pelias-sorting'), hasAdminOnlyResults), postProc.geocodeJSON(peliasConfig.api, base), postProc.sendJSON ]),