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;
}
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
}
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;
$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};
html += sprintf("Depth: %d<br />", data.depth);
html += sprintf("Parent: %d<br />", data.parent_id);
html += sprintf("Id: %s%s<br />", node.id, data._ids_merged ? data._ids_merged : "");
- html += JSON.stringify(data.attr, undefined, 4);
+ html += JSON.stringify(data.attr, undefined, 4) + "<br />";
+ html += JSON.stringify(data.leaves, undefined, 4) + "<br />";
tip.innerHTML = html;
}