summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-03-07 09:51:02 +0100
committerYorhel <git@yorhel.nl>2009-03-07 09:51:02 +0100
commit37196fc10d36249a525b07c1d74489bf259bde99 (patch)
tree0144c6e7a605a363f3a72de95a9ad1cb1e38c7a6 /lib
parent0680666a8659e75a90d581f8f3a0e3172c16bcd1 (diff)
Replacing random VN counts with actual data on tag pages
Just prototyping, current implementation is too slow for actual use.
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/Tags.pm5
-rw-r--r--lib/VNDB/Handler/Tags.pm4
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm
index e6607a2a..dfa9b6b3 100644
--- a/lib/VNDB/DB/Tags.pm
+++ b/lib/VNDB/DB/Tags.pm
@@ -44,7 +44,10 @@ sub dbTagGet {
}
if($o{what} =~ /childs\((\d+)\)/) {
- $_->{childs} = $self->dbAll(q|SELECT lvl, tag, name FROM tag_tree(?, ?, true)|, $_->{id}, $1) for (@$r);
+ $_->{childs} = $self->dbAll(
+ q|SELECT lvl, tag, name, COALESCE((SELECT COUNT(*) FROM tags_vn_bayesian tb WHERE tb.tag = tt.tag), 0) AS vns FROM tag_tree(?, ?, true) tt|,
+ $_->{id}, $1
+ ) for (@$r);
}
#if(@$r && $o{what} =~ /(?:parents)/) {
diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm
index b0e698dc..88fa96ef 100644
--- a/lib/VNDB/Handler/Tags.pm
+++ b/lib/VNDB/Handler/Tags.pm
@@ -148,7 +148,7 @@ sub _childtags {
for my $p (sort { @{$b->{childs}} <=> @{$a->{childs}} } @tags) {
li;
a href => "/g$p->{tag}", $p->{name};
- b class => 'grayedout', ' ('.(int(rand()*100)).')';
+ b class => 'grayedout', " ($p->{vns})";
end, next if !@{$p->{childs}};
ul;
for (0..$#{$p->{childs}}) {
@@ -156,7 +156,7 @@ sub _childtags {
li;
txt '> ';
a href => "/g$p->{childs}[$_]{tag}", $p->{childs}[$_]{name};
- b class => 'grayedout', ' ('.(int(rand()*50)).')';
+ b class => 'grayedout', " ($p->{childs}[$_]{vns})";
end;
}
if(@{$p->{childs}} > 6) {