refactor in order not to tamper the dataview results data

This commit is contained in:
Eneko Lakasta 2018-08-29 15:06:48 +02:00
parent 8ef260972d
commit 732f891850
2 changed files with 10 additions and 11 deletions

View File

@ -59,17 +59,11 @@ DataviewBackend.prototype.getDataview = function (mapConfigProvider, user, param
return callback(error);
}
dataview.getResult(pg, overrideParams, function (err, dataviewResult) {
dataview.getResult(pg, overrideParams, function (err, dataviewResult, stats = {}) {
if (err) {
return callback(err);
}
const stats = {};
if (dataviewResult && dataviewResult.usesOverviews) {
stats.usesOverviews = dataviewResult.usesOverviews;
}
return callback(null, dataviewResult, stats);
});
});

View File

@ -21,7 +21,7 @@ function getPGTypeName (pgType) {
module.exports = class BaseDataview {
getResult (psql, override, callback) {
this.sql(psql, override, (err, query, flags = { usesOverviews : false }) => {
this.sql(psql, override, (err, query, flags = null) => {
if (err) {
return callback(err);
}
@ -33,10 +33,15 @@ module.exports = class BaseDataview {
result = this.format(result, override);
result.type = this.getType();
result.usesOverviews = flags.usesOverviews;
return callback(null, result);
//Overviews looging
const stats = {};
if (flags && flags.usesOverviews) {
stats.usesOverviews = true;
}
return callback(null, result, stats);
}, true); // use read-only transaction
});
}