Move variable declaration close to the place that it's used

This commit is contained in:
Daniel García Aubert 2017-12-11 18:47:20 +01:00
parent b1f788fb57
commit 446449bbde

View File

@ -142,10 +142,6 @@ module.exports = class AggregationMapConfigAdapter {
return resolve({ layer, index, adapted: false }); return resolve({ layer, index, adapted: false });
} }
const threshold = layer.options.aggregation && layer.options.aggregation.threshold ?
layer.options.aggregation.threshold :
1e5;
const aggregationMetadata = queryUtils.getAggregationMetadata({ query: layer.options.sql }); const aggregationMetadata = queryUtils.getAggregationMetadata({ query: layer.options.sql });
connection.query(aggregationMetadata, (err, res) => { connection.query(aggregationMetadata, (err, res) => {
@ -154,6 +150,11 @@ module.exports = class AggregationMapConfigAdapter {
} }
const estimatedFeatureCount = res.rows[0].count; const estimatedFeatureCount = res.rows[0].count;
const threshold = layer.options.aggregation && layer.options.aggregation.threshold ?
layer.options.aggregation.threshold :
1e5;
const geometryType = res.rows[0].type; const geometryType = res.rows[0].type;
if (estimatedFeatureCount < threshold) { if (estimatedFeatureCount < threshold) {