Browse Source

use shorter function syntax

query-for-venues-on-admin-only
Stephen Hess 7 years ago
parent
commit
53268cf337
  1. 55
      controller/predicates/has_results_at_layers.js

55
controller/predicates/has_results_at_layers.js

@ -8,36 +8,39 @@ const stackTraceLine = require('../../helper/stackTraceLine');
// example usage: determining if the response contains only admin results // example usage: determining if the response contains only admin results
module.exports = { module.exports = {
any: (layers) => (request, response) => { any(layers) {
const has_results_at_any_layer = !_.isEmpty( return (request, response) => {
_.intersection( const has_results_at_any_layer = !_.isEmpty(
// convert layers to an array if it isn't already one _.intersection(
_.castArray(layers), // convert layers to an array if it isn't already one
// pull all the layer properties into an array _.castArray(layers),
_.map(response.data, _.property('layer')) // pull all the layer properties into an array
)); _.map(response.data, _.property('layer'))
));
debugLog.push(request, () => ({
reply: {[layers]: has_results_at_any_layer},
stack_trace: stackTraceLine()
}));
return has_results_at_any_layer;
debugLog.push(request, () => ({
reply: {[layers]: has_results_at_any_layer},
stack_trace: stackTraceLine()
}));
return has_results_at_any_layer;
};
}, },
all: (layers) => (request, response) => { all(layers) {
const has_results_at_all_layers = _.isEmpty( return (request, response) => {
_.difference( const has_results_at_all_layers = _.isEmpty(
_.map(response.data, _.property('layer')), _.difference(
_.castArray(layers) _.map(response.data, _.property('layer')),
) _.castArray(layers)
); )
);
debugLog.push(request, () => ({ debugLog.push(request, () => ({
reply: {[layers]: has_results_at_all_layers}, reply: {[layers]: has_results_at_all_layers},
stack_trace: stackTraceLine() stack_trace: stackTraceLine()
})); }));
return has_results_at_all_layers; return has_results_at_all_layers;
};
} }
}; };

Loading…
Cancel
Save