From: Tim Bunce Date: Wed, 19 Sep 2012 16:36:01 +0000 (+0100) Subject: basic leaves pass-thru X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e78b28ca502f26f81baa5eb6f09d0dd810f7d379;p=p5sagit%2FDevel-Size.git basic leaves pass-thru --- diff --git a/memnodes.pl b/memnodes.pl index 3681e03..17b548f 100644 --- a/memnodes.pl +++ b/memnodes.pl @@ -32,11 +32,12 @@ $dbh->do(q{ kids_size integer, kids_node_count integer, child_ids text, - attr_json text + attr_json text, + leaves_json text ) }); my $node_ins_sth = $dbh->prepare(q{ - INSERT INTO node VALUES (?,?,?,?, ?,?,?,?,?) + INSERT INTO node VALUES (?,?,?,?, ?,?,?,?,?,?) }); my @stack; @@ -73,11 +74,12 @@ sub leave_node { } if ($dbh) { my $attr_json = $j->encode($x->{attr}); + my $leaves_json = $j->encode($x->{leaves}); $node_ins_sth->execute( $x->{id}, $x->{name}, $x->{depth}, $x->{parent_id}, $x->{self_size}, $x->{kids_size}, $x->{kids_node_count}, $x->{child_id} ? join(",", @{$x->{child_id}}) : undef, - $attr_json, + $attr_json, $leaves_json, ); # XXX attribs } diff --git a/static/MemView.pl b/static/MemView.pl index fa4affc..29eb2b3 100755 --- a/static/MemView.pl +++ b/static/MemView.pl @@ -56,6 +56,8 @@ sub _fetch_node_tree { my $node = MemView->selectrow_hashref("select * from node where id = ?", undef, $id) or die "Node '$id' not found"; $node->{attr}{self} = $j->decode(delete $node->{attr_json}); + $node->{leaves} = $j->decode(delete $node->{leaves_json}); + if ($node->{child_ids}) { my @child_ids = split /,/, $node->{child_ids}; my $children; @@ -67,8 +69,9 @@ sub _fetch_node_tree { $child->{name} = "$node->{name} + $child->{name}"; $child->{$_} += $node->{$_} for (qw(self_size)); $child->{$_} = $node->{$_} for (qw(parent_id)); - Dwarn $node; $child->{attr}{$node->{id}} = $node->{attr}; + $child->{leaves}{$_} += $node->{leaves}{$_} + for keys %{ $node->{leaves} }; $child->{_ids_merged} .= ",$node->{id}"; my @child_ids = split /,/, $node->{child_ids}; diff --git a/static/public/.tm.js.swp b/static/public/.tm.js.swp index 041222f..2564ba6 100644 Binary files a/static/public/.tm.js.swp and b/static/public/.tm.js.swp differ diff --git a/static/public/tm.js b/static/public/tm.js index 7dde7e9..bd689cd 100644 --- a/static/public/tm.js +++ b/static/public/tm.js @@ -107,7 +107,8 @@ function init(){ html += sprintf("Depth: %d
", data.depth); html += sprintf("Parent: %d
", data.parent_id); html += sprintf("Id: %s%s
", node.id, data._ids_merged ? data._ids_merged : ""); - html += JSON.stringify(data.attr, undefined, 4); + html += JSON.stringify(data.attr, undefined, 4) + "
"; + html += JSON.stringify(data.leaves, undefined, 4) + "
"; tip.innerHTML = html; }