dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29816
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15130: PT ER, pivot performance improvement.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 15130 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-05-01 12:46:34 +0200
message:
PT ER, pivot performance improvement.
modified:
dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js
dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js
dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js
dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js 2014-04-22 14:48:02 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js 2014-05-01 10:44:27 +0000
@@ -5816,6 +5816,9 @@
web.mask.hide(ns.app.centerRegion);
if (NS.isDebug) {
+ var res = response || xResponse;
+
+ console.log("Number of records", res.rows.length);
console.log("Number of cells", table.tdCount);
console.log("DATA", (ns.app.dateCreate - ns.app.dateData) / 1000);
console.log("CREATE", (ns.app.dateRender - ns.app.dateCreate) / 1000);
=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js 2014-04-22 14:48:02 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js 2014-05-01 10:44:27 +0000
@@ -1349,12 +1349,12 @@
// add parents if more than 1 floor
if (nAxisHeight > 1) {
- for (var i = 1, allFloor; i < nAxisHeight; i++) {
- allFloor = aaAllFloorObjects[i];
+ for (var i = 1, aAllFloor; i < nAxisHeight; i++) {
+ aAllFloor = aaAllFloorObjects[i];
- //for (var j = 0, obj, doorCount = 0, span = aFloorSpan[i - 1], parentObj = aaAllFloorObjects[i - 1][0]; j < allFloor.length; j++) {
- for (var j = 0, doorCount = 0, span = aFloorSpan[i - 1]; j < allFloor.length; j++) {
- allFloor[j].parent = aaAllFloorObjects[i - 1][j];
+ //for (var j = 0, obj, doorCount = 0, span = aFloorSpan[i - 1], parentObj = aaAllFloorObjects[i - 1][0]; j < aAllFloor.length; j++) {
+ for (var j = 0, doorCount = 0, span = aFloorSpan[i - 1]; j < aAllFloor.length; j++) {
+ aAllFloor[j].parent = aaAllFloorObjects[i - 1][j];
//doorCount++;
@@ -1370,11 +1370,11 @@
if (aaAllFloorObjects.length) {
// set span to second lowest span number: if aFloorSpan == [15,3,15,1], set span to 3
- var span = nAxisHeight > 1 ? support.prototype.array.sort(Ext.clone(aFloorSpan))[1] : nAxisWidth,
- allFloorObjectsLast = aaAllFloorObjects[aaAllFloorObjects.length - 1];
+ var nSpan = nAxisHeight > 1 ? support.prototype.array.sort(Ext.clone(aFloorSpan))[1] : nAxisWidth,
+ aAllFloorObjectsLast = aaAllFloorObjects[aaAllFloorObjects.length - 1];
- for (var i = 0, leaf, parentUuids, obj, leafUuids = []; i < allFloorObjectsLast.length; i++) {
- leaf = allFloorObjectsLast[i];
+ for (var i = 0, leaf, parentUuids, obj, leafUuids = []; i < aAllFloorObjectsLast.length; i++) {
+ leaf = aAllFloorObjectsLast[i];
leafUuids.push(leaf.uuid);
parentUuids = [];
obj = leaf;
@@ -1389,9 +1389,9 @@
leaf.uuids = Ext.clone(parentUuids);
// add uuid for all leaves
- if (leafUuids.length === span) {
- for (var j = (i - span) + 1, leaf; j <= i; j++) {
- leaf = allFloorObjectsLast[j];
+ if (leafUuids.length === nSpan) {
+ for (var j = (i - nSpan) + 1, leaf; j <= i; j++) {
+ leaf = aAllFloorObjectsLast[j];
leaf.uuids = leaf.uuids.concat(Ext.clone(leafUuids));
}
@@ -2072,23 +2072,6 @@
doSubTotals = function(xAxis) {
return !!xLayout.showSubTotals && xAxis && xAxis.dims > 1;
-
- //var multiItemDimension = 0,
- //unique;
-
- //if (!(xLayout.showSubTotals && xAxis && xAxis.dims > 1)) {
- //return false;
- //}
-
- //unique = xAxis.xItems.unique;
-
- //for (var i = 0; i < unique.length; i++) {
- //if (unique[i].length > 1) {
- //multiItemDimension++;
- //}
- //}
-
- //return (multiItemDimension > 1);
};
doTotals = function() {
@@ -2245,7 +2228,7 @@
// [ dim, dim ] ];
// value
- for (var i = 0, valueItemsRow, valueObjectsRow, idValueMap = Ext.clone(xResponse.idValueMap); i < rowAxisSize; i++) {
+ for (var i = 0, valueItemsRow, valueObjectsRow, idValueMap = xResponse.idValueMap; i < rowAxisSize; i++) {
valueItemsRow = [];
valueObjectsRow = [];
@@ -2357,7 +2340,7 @@
}
}
- xValueObjects = Ext.clone(valueObjects);
+ xValueObjects = valueObjects;
// col subtotals
if (doSubTotals(xColAxis)) {
@@ -2571,7 +2554,7 @@
empty = [];
}
- xTotalColObjects = Ext.clone(totalColObjects);
+ xTotalColObjects = totalColObjects;
if (xColAxis && doSubTotals(xColAxis)) {
var tmp = [];
@@ -2653,7 +2636,7 @@
})];
}
- row = [].concat(dimTotalArray || [], Ext.clone(colTotal) || [], Ext.clone(grandTotal) || []);
+ row = [].concat(dimTotalArray || [], colTotal || [], grandTotal || []);
a.push(row);
}
@@ -2673,8 +2656,7 @@
// get html
return function() {
- var rows = xResponse.rows;
- htmlArray = Ext.Array.clean([].concat(getColAxisHtmlArray() || [], getRowHtmlArray() || [], getTotalHtmlArray() || []));
+ var htmlArray = Ext.Array.clean([].concat(getColAxisHtmlArray() || [], getRowHtmlArray() || [], getTotalHtmlArray() || []));
return {
html: getHtml(htmlArray),
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2014-04-29 13:54:48 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2014-05-01 10:44:27 +0000
@@ -2176,7 +2176,11 @@
};
}
- web.pivot.createTable(layout, null, xResponse, false);
+ web.mask.show(ns.app.centerRegion, 'Sorting...');
+
+ Ext.defer(function() {
+ web.pivot.createTable(layout, null, xResponse, false);
+ }, 10);
};
web.events.onColumnHeaderMouseOver = function(el) {
@@ -2286,6 +2290,9 @@
// show mask
web.mask.show(ns.app.centerRegion);
+ // timing
+ ns.app.dateData = new Date();
+
Ext.Ajax.request({
url: init.contextPath + '/api/analytics.json' + paramString,
timeout: 60000,
@@ -2307,6 +2314,8 @@
}
},
success: function(r) {
+ ns.app.dateCreate = new Date();
+
var response = api.response.Response(Ext.decode(r.responseText));
if (!response) {
@@ -2342,6 +2351,8 @@
xLayout = getSXLayout(getXLayout(layout), xResponse || response);
+ ns.app.dateSorting = new Date();
+
if (layout.sorting) {
if (!xResponse) {
xResponse = getXResponse(xLayout, response);
@@ -2357,9 +2368,15 @@
table = getHtml(xLayout, xResponse);
+ // timing
+ ns.app.dateRender = new Date();
+
ns.app.centerRegion.removeAll(true);
ns.app.centerRegion.update(table.html);
+ // timing
+ ns.app.dateTotal = new Date();
+
// after render
ns.app.layout = layout;
ns.app.xLayout = xLayout;
@@ -2381,8 +2398,21 @@
web.mask.hide(ns.app.centerRegion);
if (NS.isDebug) {
- console.log("core", ns.core);
- console.log("app", ns.app);
+ var res = response || xResponse;
+
+ console.log("Number of records", res.rows.length);
+ console.log("Number of cells", table.tdCount);
+ console.log("DATA", (ns.app.dateCreate - ns.app.dateData) / 1000);
+ console.log("CREATE", (ns.app.dateRender - ns.app.dateCreate) / 1000);
+ console.log("SORTING", (ns.app.dateRender - ns.app.dateSorting) / 1000);
+ console.log("RENDER", (ns.app.dateTotal - ns.app.dateRender) / 1000);
+ console.log("TOTAL", (ns.app.dateTotal - ns.app.dateData) / 1000);
+ console.log("layout", layout);
+ console.log("response", response);
+ console.log("xResponse", xResponse);
+ console.log("xLayout", xLayout);
+ console.log("core", ns.core);
+ console.log("app", ns.app);
}
};
}());
=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js 2014-04-30 15:46:01 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js 2014-05-01 10:38:21 +0000
@@ -255,8 +255,7 @@
};
api.layout.Layout = function(config) {
- var config = Ext.clone(config),
- layout = {},
+ var layout = {},
getValidatedDimensionArray,
validateSpecialCases;
@@ -1326,7 +1325,6 @@
// [pe-id1],
// [ou-id1, ou-id2, ou-id3, ou-id4] ]
-
// nAxisHeight
nAxisHeight = aaUniqueFloorIds.length;
//nAxisHeight = 3
@@ -1347,15 +1345,15 @@
// aFloorSpan
for (var i = 0; i < nAxisHeight; i++) {
if (aUniqueFloorWidth[i] === 1) {
- if (i === 0) { // if top floor
- aFloorSpan.push(nAxisWidth); // span max
+ if (i === 0) { // if top floor, set maximum span
+ aFloorSpan.push(nAxisWidth);
}
else {
if (xLayout.hideEmptyRows && type === 'row') {
aFloorSpan.push(nAxisWidth / aAccFloorWidth[i]);
}
- else {
- aFloorSpan.push(aFloorSpan[0]); //if just one item and not top level, span same as top level
+ else { //if just one item and not top level, use same span as top level
+ aFloorSpan.push(aFloorSpan[0]);
}
}
}
@@ -1363,7 +1361,7 @@
aFloorSpan.push(nAxisWidth / aAccFloorWidth[i]);
}
}
- //aFloorSpan = [4, 12, 1]
+ //aFloorSpan = [4, 12, 1]
// aaGuiFloorIds
@@ -1386,7 +1384,6 @@
// [o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2...] (30)
// ]
-
// aaAllFloorIds
for (var i = 0, aAllFloorIds, aUniqueFloorIds, span, factor; i < nAxisHeight; i++) {
aAllFloorIds = [];
@@ -1409,7 +1406,6 @@
// [o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2, o1, o2] (30)
// ]
-
// aCondoId
for (var i = 0, id; i < nAxisWidth; i++) {
id = '';
@@ -1422,7 +1418,7 @@
aCondoId.push(id);
}
}
- //aCondoId = [ id11+id21+id31, id12+id22+id32, ... ]
+ //aCondoId = [ id11+id21+id31, id12+id22+id32, ... ]
// allObjects
@@ -1460,7 +1456,6 @@
obj[spanType] = aFloorSpan[i];
// children
- //obj.children = Ext.isDefined(aFloorSpan[i + 1]) ? aFloorSpan[i] / aFloorSpan[i + 1] : 0;
obj.children = obj.leaf ? 0 : aFloorSpan[i];
// first sibling
@@ -1485,12 +1480,12 @@
// add parents if more than 1 floor
if (nAxisHeight > 1) {
- for (var i = 1, allFloor; i < nAxisHeight; i++) {
- allFloor = aaAllFloorObjects[i];
+ for (var i = 1, aAllFloor; i < nAxisHeight; i++) {
+ aAllFloor = aaAllFloorObjects[i];
- //for (var j = 0, obj, doorCount = 0, span = aFloorSpan[i - 1], parentObj = aaAllFloorObjects[i - 1][0]; j < allFloor.length; j++) {
- for (var j = 0, doorCount = 0, span = aFloorSpan[i - 1]; j < allFloor.length; j++) {
- allFloor[j].parent = aaAllFloorObjects[i - 1][j];
+ //for (var j = 0, obj, doorCount = 0, span = aFloorSpan[i - 1], parentObj = aaAllFloorObjects[i - 1][0]; j < aAllFloor.length; j++) {
+ for (var j = 0, doorCount = 0, span = aFloorSpan[i - 1]; j < aAllFloor.length; j++) {
+ aAllFloor[j].parent = aaAllFloorObjects[i - 1][j];
//doorCount++;
@@ -1506,11 +1501,11 @@
if (aaAllFloorObjects.length) {
// set span to second lowest span number: if aFloorSpan == [15,3,15,1], set span to 3
- var span = nAxisHeight > 1 ? support.prototype.array.sort(Ext.clone(aFloorSpan))[1] : nAxisWidth,
- allFloorObjectsLast = aaAllFloorObjects[aaAllFloorObjects.length - 1];
+ var nSpan = nAxisHeight > 1 ? support.prototype.array.sort(Ext.clone(aFloorSpan))[1] : nAxisWidth,
+ aAllFloorObjectsLast = aaAllFloorObjects[aaAllFloorObjects.length - 1];
- for (var i = 0, leaf, parentUuids, obj, leafUuids = []; i < allFloorObjectsLast.length; i++) {
- leaf = allFloorObjectsLast[i];
+ for (var i = 0, leaf, parentUuids, obj, leafUuids = []; i < aAllFloorObjectsLast.length; i++) {
+ leaf = aAllFloorObjectsLast[i];
leafUuids.push(leaf.uuid);
parentUuids = [];
obj = leaf;
@@ -1525,10 +1520,10 @@
leaf.uuids = Ext.clone(parentUuids);
// add uuid for all leaves
- if (leafUuids.length === span) {
- for (var j = (i - span) + 1, leaf; j <= i; j++) {
- leaf = allFloorObjectsLast[j];
- leaf.uuids = leaf.uuids.concat(Ext.clone(leafUuids));
+ if (leafUuids.length === nSpan) {
+ for (var j = (i - nSpan) + 1, leaf; j <= i; j++) {
+ leaf = aAllFloorObjectsLast[j];
+ leaf.uuids = leaf.uuids.concat(leafUuids);
}
leafUuids = [];
@@ -1540,13 +1535,11 @@
for (var i = 0; i < aaAllFloorObjects.length; i++) {
for (var j = 0, object; j < aaAllFloorObjects[i].length; j++) {
object = aaAllFloorObjects[i][j];
-//console.log(object.uuid, object);
+
uuidObjectMap[object.uuid] = object;
}
}
-//console.log("aaAllFloorObjects", aaAllFloorObjects);
-
return {
type: type,
items: aDimensions,
@@ -1947,11 +1940,13 @@
getTotalHtmlArray,
getHtml,
getUniqueFactor = function(xAxis) {
+ var unique;
+
if (!xAxis) {
return null;
}
- var unique = xAxis.xItems.unique;
+ unique = xAxis.xItems.unique;
if (unique) {
return unique.length < 2 ? 1 : (xAxis.size / unique[0].length);
@@ -2000,7 +1995,7 @@
// number of cells
tdCount = tdCount + 1;
- // Background color from legend set
+ // background color from legend set
if (isNumeric && xLayout.legendSet) {
var value = parseFloat(config.value);
mapLegends = xLayout.legendSet.mapLegends;
@@ -2024,7 +2019,7 @@
cls += isValue ? ' pointer' : '';
cls += bgColor ? ' legend' : (config.cls ? ' ' + config.cls : '');
- // sorting
+ // if sorting
if (Ext.isString(metaDataId)) {
cls += ' td-sortable';
@@ -2037,7 +2032,6 @@
html += '<td ' + (config.uuid ? ('id="' + config.uuid + '" ') : '');
html += ' class="' + cls + '" ' + colSpan + rowSpan
-
if (bgColor) {
html += '>';
html += '<div class="legendCt">';
@@ -2045,19 +2039,6 @@
html += '<div class="arrowCt ' + config.cls + '">';
html += '<div class="arrow" style="border-bottom:8px solid transparent; border-right:8px solid ' + bgColor + '"> </div>';
html += '</div></div></div></td>';
-
- //cls = 'legend';
- //cls += config.hidden ? ' td-hidden' : '';
- //cls += config.collapsed ? ' td-collapsed' : '';
-
- //html += '<td class="' + cls + '" ';
- //html += colSpan + rowSpan + '>';
- //html += '<div class="legendCt">';
- //html += '<div style="display:table-cell; padding:' + displayDensity + '; font-size:' + fontSize + '"';
- //html += config.cls ? ' class="' + config.cls + '">' : '';
- //html += htmlValue + '</div>';
- //html += '<div class="legendColor" style="background-color:' + bgColor + '"> </div>';
- //html += '</div></td>';
}
else {
html += 'style="padding:' + displayDensity + '; font-size:' + fontSize + ';"' + '>' + htmlValue + '</td>';
@@ -2068,23 +2049,6 @@
doSubTotals = function(xAxis) {
return !!xLayout.showSubTotals && xAxis && xAxis.dims > 1;
-
- //var multiItemDimension = 0,
- //unique;
-
- //if (!(xLayout.showSubTotals && xAxis && xAxis.dims > 1)) {
- //return false;
- //}
-
- //unique = xAxis.xItems.unique;
-
- //for (var i = 0; i < unique.length; i++) {
- //if (unique[i].length > 1) {
- //multiItemDimension++;
- //}
- //}
-
- //return (multiItemDimension > 1);
};
doTotals = function() {
@@ -2134,6 +2098,7 @@
// sortable column headers. last dim only.
if (i === xColAxis.dims - 1 && doSortableColumnHeaders()) {
+
//condoId = xColAxis.ids[j].split('-').join('');
condoId = xColAxis.ids[j];
}
@@ -2220,7 +2185,7 @@
// [ dim, dim ] ];
// value
- for (var i = 0, valueItemsRow, valueObjectsRow, idValueMap = Ext.clone(xResponse.idValueMap); i < rowAxisSize; i++) {
+ for (var i = 0, valueItemsRow, valueObjectsRow, idValueMap = xResponse.idValueMap; i < rowAxisSize; i++) {
valueItemsRow = [];
valueObjectsRow = [];
@@ -2232,7 +2197,7 @@
//id = (xColAxis ? support.prototype.str.replaceAll(xColAxis.ids[j], '-', '') : '') + (xRowAxis ? support.prototype.str.replaceAll(xRowAxis.ids[i], '-', '') : '');
id = (xColAxis ? xColAxis.ids[j] : '') + (xRowAxis ? xRowAxis.ids[i] : '');
- // value html element id
+ // value html element id
uuid = Ext.data.IdGenerator.get('uuid').generate();
// get uuids array from colaxis/rowaxis leaf
@@ -2314,17 +2279,17 @@
// if value row is empty
if (isValueRowEmpty) {
- // Hide values by adding collapsed = true to all items
+ // hide values by adding collapsed = true to all items
for (var j = 0; j < valueRow.length; j++) {
valueRow[j].collapsed = true;
}
- // Hide totals by adding collapsed = true to all items
+ // hide totals by adding collapsed = true to all items
if (doTotals()) {
totalValueObjects[i].collapsed = true;
}
- // Hide/reduce parent dim span
+ // hide/reduce parent dim span
dimLeaf = axisAllObjects[i][xRowAxis.dims-1];
recursiveReduce(dimLeaf);
}
@@ -2332,7 +2297,7 @@
}
}
- xValueObjects = Ext.clone(valueObjects);
+ xValueObjects = valueObjects;
// col subtotals
if (doSubTotals(xColAxis)) {
@@ -2411,7 +2376,7 @@
tmpAxisAllObjects.push(axisAllObjects[i]);
collapsed.push(!!axisAllObjects[i][0].collapsed);
- // Insert subtotal after last objects
+ // insert subtotal after last objects
if (!Ext.isArray(axisAllObjects[i+1]) || !!axisAllObjects[i+1][0].root) {
tmpAxisAllObjects.push(getAxisSubTotalRow(collapsed));
@@ -2487,7 +2452,7 @@
totalValueObjects = tmpTotalValueObjects;
}
- // Merge dim, value, total
+ // merge dim, value, total
for (var i = 0, row; i < xValueObjects.length; i++) {
row = [];
@@ -2504,7 +2469,7 @@
mergedObjects.push(row);
}
- // Create html items
+ // create html items
for (var i = 0, row; i < mergedObjects.length; i++) {
row = [];
@@ -2524,7 +2489,7 @@
if (xRowAxis && doTotals()) {
var xTotalColObjects;
- // Total col items
+ // total col items
for (var i = 0, total = 0, empty = []; i < valueObjects[0].length; i++) {
for (var j = 0, obj; j < valueObjects.length; j++) {
obj = valueObjects[j][i];
@@ -2546,7 +2511,7 @@
empty = [];
}
- xTotalColObjects = Ext.clone(totalColObjects);
+ xTotalColObjects = totalColObjects;
if (xColAxis && doSubTotals(xColAxis)) {
var tmp = [];
@@ -2575,7 +2540,7 @@
xTotalColObjects = tmp;
}
- // Total col html items
+ // total col html items
for (var i = 0; i < xTotalColObjects.length; i++) {
a.push(getTdHtml(xTotalColObjects[i]));
}
@@ -2628,7 +2593,7 @@
})];
}
- row = [].concat(dimTotalArray || [], Ext.clone(colTotal) || [], Ext.clone(grandTotal) || []);
+ row = [].concat(dimTotalArray || [], colTotal || [], grandTotal || []);
a.push(row);
}