mirror of https://github.com/pelias/api.git
Lily He
8 years ago
3 changed files with 23 additions and 5 deletions
@ -1,13 +1,18 @@
|
||||
const _ = require('lodash'); |
||||
const Debug = require('../../helper/debug'); |
||||
const debugLog = new Debug('controller:predicates:is_admin_only_analysis'); |
||||
|
||||
module.exports = (request, response) => { |
||||
if (!request.clean.hasOwnProperty('parsed_text')) { |
||||
debugLog.push(request, false + '(no parsed_text)'); |
||||
return false; |
||||
} |
||||
|
||||
// return true only if all non-admin properties of parsed_text are empty
|
||||
return ['number', 'street', 'query', 'category', 'postalcode'].every((prop) => { |
||||
const is_admin_only_analysis = ['number', 'street', 'query', 'category', 'postalcode'].every((prop) => { |
||||
return _.isEmpty(request.clean.parsed_text[prop]); |
||||
}); |
||||
|
||||
debugLog.push(request, is_admin_only_analysis); |
||||
return is_admin_only_analysis; |
||||
}; |
||||
|
@ -1,9 +1,13 @@
|
||||
const _ = require('lodash'); |
||||
|
||||
const Debug = require('../../helper/debug'); |
||||
const debugLog = new Debug('controller:predicates:is_coarse_reverse'); |
||||
const non_coarse_layers = ['address', 'street', 'venue']; |
||||
|
||||
module.exports = (req, res) => { |
||||
// returns true if layers is undefined, empty, or contains 'address', 'street', or 'venue'
|
||||
return !_.isEmpty(req.clean.layers) && |
||||
const is_coarse_reverse = !_.isEmpty(req.clean.layers) && |
||||
_.isEmpty(_.intersection(req.clean.layers, non_coarse_layers)); |
||||
|
||||
debugLog.push(req, is_coarse_reverse); |
||||
return is_coarse_reverse; |
||||
}; |
||||
|
Loading…
Reference in new issue