Revert error behaviour for estimatedFeatureCount

Keep current production behavior of ignoreing errors when computing this stat and returning -1.
This is done as to no introduce any instability in production at the moment.
This commit is contained in:
Javier Goizueta
2018-05-21 11:44:52 +02:00
parent 4e99ff1c39
commit 38e55367b1
@@ -34,11 +34,16 @@ MapnikLayerStats.prototype.is = function (type) {
return this._types[type] ? this._types[type] : false;
};
function queryPromise(dbConnection, query, adaptResults) {
function queryPromise(dbConnection, query, adaptResults, errorHandler) {
return new Promise(function(resolve, reject) {
dbConnection.query(query, function (err, res) {
if (err) {
reject(err);
if (errorHandler) {
errorHandler(err);
}
else {
reject(err);
}
}
else {
resolve(adaptResults(res));
@@ -71,11 +76,11 @@ function _getSQL(ctx, query, type='pre', zoom=0) {
}
function _estimatedFeatureCount(ctx) {
// TODO: restore -1 on errors behavior?
return queryPromise(
ctx.dbConnection,
_getSQL(ctx, queryUtils.getQueryRowEstimation),
res => ({ estimatedFeatureCount: res.rows[0].rows })
res => ({ estimatedFeatureCount: res.rows[0].rows }),
() => ({ estimatedFeatureCount: -1 })
);
}