From db14520ad041248808d423008836fe66a49d6dd7 Mon Sep 17 00:00:00 2001 From: miker Date: Sun, 1 Oct 2006 18:43:16 +0000 Subject: [PATCH] simplified from-pruning git-svn-id: svn://svn.open-ils.org/ILS/trunk@6310 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/reports/oils_rpt_builder.js | 40 +++++++++++--------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/Open-ILS/web/reports/oils_rpt_builder.js b/Open-ILS/web/reports/oils_rpt_builder.js index b6ccdee18e..f15f43b1ce 100644 --- a/Open-ILS/web/reports/oils_rpt_builder.js +++ b/Open-ILS/web/reports/oils_rpt_builder.js @@ -202,36 +202,24 @@ function oilsRptPruneFromClause(relation, node) { // first, descend into the tree, and prune leaves first if( node[i].join ) { oilsRptPruneFromClause(relation, node[i].join); - if(node[i].join && oilsRptObjectKeys(node[i].join).length == 0) - delete node[i].join; - - /* if there are no items in the select, where or having clauses with a relation - matching this nodes alias, we can safely remove this node from the tree */ - if( node[i].alias == relation ) { - if( !grep(oilsRpt.def.select, - function(i){ return (i.relation == node[i].alias)}) - && !grep(oilsRpt.def.where, - function(i){ return (i.relation == node[i].alias)}) - && !grep(oilsRpt.def.having, - function(i){ return (i.relation == node[i].alias)}) - ) { - delete node[i]; - return true; - } - } + if(oilsRptObjectKeys(node[i].join).length == 0) delete node[i].join; } + } - // now, if we're at the leaf to remove, remove it - if( node[i].alias == relation ) { - if( node[i].join ) { - /* if we have subtrees, don't delete our tree node */ - return false; - } else { - delete node[i]; - return true; - } + // if we're at an unused empty leaf, remove it + if( !node[i].join ) { + if( !grep(oilsRpt.def.select, + function(i){ return (i.relation == node[i].alias)}) + && !grep(oilsRpt.def.where, + function(i){ return (i.relation == node[i].alias)}) + && !grep(oilsRpt.def.having, + function(i){ return (i.relation == node[i].alias)}) + ) { + delete node[i]; + return true; } } + return false; } -- 2.11.0