Last active
May 7, 2018 16:42
-
-
Save yianni-ververis/bf749fe306c88198de2b6ceb043712e3 to your computer and use it in GitHub Desktop.
HypeCube fetch all results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can not get all results as an anonymous user in mashup.