[IMP] massive optimization of the graph view code: more efficient access to values and smarter code to avoid reading uselessly many cells (graph view in web_graph)
bzr revid: ged@openerp.com-20140409093920-xqls2o6j6tocgf6l
This commit is contained in:
parent
05ec7d45ba
commit
1330bb615e
|
@ -453,12 +453,25 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({
|
|||
build_rows: function (raw) {
|
||||
var self = this,
|
||||
pivot = this.pivot,
|
||||
m, cell;
|
||||
m, i, cell;
|
||||
|
||||
return _.map(pivot.rows.headers, function (row) {
|
||||
var cells = [];
|
||||
var pivot_cells = [];
|
||||
for (i = 0; i < pivot.cells.length; i++) {
|
||||
if (pivot.cells[i].x == row.id || pivot.cells[i].y == row.id) {
|
||||
pivot_cells.push(pivot.cells[i]);
|
||||
}
|
||||
}
|
||||
_.each(pivot.get_cols_leaves(), function (col) {
|
||||
var values = pivot.get_values(row.id,col.id);
|
||||
var values;
|
||||
for (i = 0; i < pivot_cells.length; i++) {
|
||||
if (pivot_cells[i].x == col.id || pivot_cells[i].y == col.id) {
|
||||
values = pivot_cells[i].values;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!values) { values = new Array(pivot.measures.length);}
|
||||
for (m = 0; m < pivot.measures.length; m++) {
|
||||
cells.push(self.make_cell(row,col,values[m], m, raw));
|
||||
}
|
||||
|
|
|
@ -81,10 +81,15 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({
|
|||
},
|
||||
|
||||
get_values: function (id1, id2, default_values) {
|
||||
var cell = _.findWhere(this.cells, {x: Math.min(id1, id2), y: Math.max(id1, id2)});
|
||||
return (cell !== undefined) ?
|
||||
cell.values :
|
||||
(default_values || new Array(this.measures.length));
|
||||
var cells = this.cells,
|
||||
x = Math.min(id1, id2),
|
||||
y = Math.max(id1, id2);
|
||||
for (var i = 0; i < cells.length; i++) {
|
||||
if (cells[i].x == x && cells[i].y == y) {
|
||||
return cells[i].values;
|
||||
}
|
||||
}
|
||||
return (default_values || new Array(this.measures.length));
|
||||
},
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue