mirror of https://github.com/pelias/api.git
Diana Shkolnikov
9 years ago
31 changed files with 201 additions and 160 deletions
@ -1,21 +0,0 @@
|
||||
/** |
||||
* Utility for calculating query result size |
||||
* incorporating padding for dedupe process |
||||
*/ |
||||
|
||||
var SIZE_PADDING = 2; |
||||
|
||||
/** |
||||
* Add padding or set to 1 |
||||
* |
||||
* @param {number} cleanSize |
||||
* @returns {number} |
||||
*/ |
||||
module.exports = function calculateSize(cleanSize) { |
||||
switch (cleanSize || 1) { |
||||
case 1: |
||||
return 1; |
||||
default: |
||||
return cleanSize * SIZE_PADDING; |
||||
} |
||||
}; |
@ -0,0 +1,35 @@
|
||||
var _ = require('lodash'); |
||||
|
||||
var SIZE_PADDING = 2; |
||||
|
||||
/** |
||||
* Utility for calculating query result size |
||||
* incorporating padding for dedupe process |
||||
*/ |
||||
function setup() { |
||||
return function setQuerySize(req, res, next) { |
||||
if (_.isUndefined(req.clean) || _.isUndefined(req.clean.size)) { |
||||
return next(); |
||||
} |
||||
|
||||
req.clean.querySize = calculateSize(req.clean.size); |
||||
next(); |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* Add padding or set to 1 |
||||
* |
||||
* @param {number} cleanSize |
||||
* @returns {number} |
||||
*/ |
||||
function calculateSize(cleanSize) { |
||||
switch (cleanSize || 1) { |
||||
case 1: |
||||
return 1; |
||||
default: |
||||
return cleanSize * SIZE_PADDING; |
||||
} |
||||
} |
||||
|
||||
module.exports = setup; |
Loading…
Reference in new issue