Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HypeCube fetch all results
me.getAllresults = function (dimensions, measures) {
var deferred = $q.defer(),
promises = [],
qTotalData = [],
qTotalData2 = [],
qDimensions = [],
qMeasures = [];
if (dimensions.length) {
angular.forEach(dimensions, function(value, key) {
qDimensions.push({
qDef: {
qGrouping: "N",
qFieldDefs: [ value ],
qSortCriterias: [{
qSortByAscii: (value==='SeriesName') ? 1 : 0,
}],
}
});
});
}
if (measures.length) {
angular.forEach(measures, function(value, key) {
qMeasures.push({
qDef : {
qDef : value
}
});
});
}
app.obj.app.createCube({
qDimensions : qDimensions,
qMeasures : qMeasures
}).then(function(model) {
model.getHyperCubeData('/qHyperCubeDef', [{qTop: 0, qWidth: 20, qLeft: 0, qHeight: 500}]).then(function(data) {
var columns = model.layout.qHyperCube.qSize.qcx;
var totalheight = model.layout.qHyperCube.qSize.qcy;
var pageheight = Math.floor(10000 / columns);
var numberOfPages = Math.ceil(totalheight / pageheight);
if (numberOfPages==1) {
deferred.resolve(data.qDataPages[0].qMatrix);
} else {
utility.log('Download Started on', new Date());
var Promise = $q;
var promises = Array.apply(null, Array(numberOfPages)).map(function(data, index) {
var page = {
qTop: (pageheight * index) + index,
qLeft: 0,
qWidth: columns,
qHeight: pageheight,
index: index
};
return model.getHyperCubeData('/qHyperCubeDef', [page]);
}, this);
Promise.all(promises).then(function(data) {
for (var j=0; j<data.length; j++) {
for (var k=0; k<data[j].qDataPages[0].qMatrix.length; k++) {
qTotalData.push(data[j].qDataPages[0].qMatrix[k])
}
}
utility.log('Download Ended on', new Date());
deferred.resolve(qTotalData);
});
}
})
})
return deferred.promise;
}
@jlgjosue

This comment has been minimized.

Copy link

@jlgjosue jlgjosue commented May 7, 2018

I can not get all results as an anonymous user in mashup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.