summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/Tags.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-03-08 12:20:02 +0100
committerYorhel <git@yorhel.nl>2009-03-08 12:20:02 +0100
commitbfd587563ae9fede8299bf97dfea1e07c2d4fefe (patch)
tree48de5e925de11577f983899c9ec747501160d98b /lib/VNDB/DB/Tags.pm
parent68ab69f9339741dd3a1f50dd5321e540e8361b88 (diff)
Added caching of tags_vn_bayesian and the VN count for tags
Updated hourly by Multi. May want to look for a better way to update this cache, because I'm afraid the current tags_vn_calc() is going to perform very badly on larger databases.
Diffstat (limited to 'lib/VNDB/DB/Tags.pm')
-rw-r--r--lib/VNDB/DB/Tags.pm17
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm
index 27485229..a50e6d38 100644
--- a/lib/VNDB/DB/Tags.pm
+++ b/lib/VNDB/DB/Tags.pm
@@ -32,7 +32,7 @@ sub dbTagGet {
);
my($r, $np) = $self->dbPage(\%o, q|
- SELECT t.id, t.meta, t.name, t.alias, t.description
+ SELECT t.id, t.meta, t.name, t.alias, t.description, t.c_vns
FROM tags t
!W
ORDER BY !s|,
@@ -40,22 +40,13 @@ sub dbTagGet {
);
if($o{what} =~ /parents\((\d+)\)/) {
- $_->{parents} = $self->dbAll(q|SELECT lvl, tag, name FROM tag_tree(?, ?, false)|, $_->{id}, $1) for (@$r);
+ $_->{parents} = $self->dbAll(q|SELECT lvl, tag, name, c_vns FROM tag_tree(?, ?, false)|, $_->{id}, $1) for (@$r);
}
if($o{what} =~ /childs\((\d+)\)/) {
- $_->{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);
+ $_->{childs} = $self->dbAll(q|SELECT lvl, tag, name, c_vns FROM tag_tree(?, ?, true)|, $_->{id}, $1) for (@$r);
}
- #if(@$r && $o{what} =~ /(?:parents)/) {
- #my %r = map {
- # ($r->[$_]{id}, $_)
- #} 0..$#$r;
- #}
-
return wantarray ? ($r, $np) : $r;
}
@@ -178,7 +169,7 @@ sub dbTagVNs {
my($r, $np) = $self->dbPage(\%o, q|
SELECT tb.tag, tb.vid, tb.users, tb.rating, tb.spoiler, vr.title, vr.original, v.c_languages, v.c_released, v.c_platforms, v.c_popularity
- FROM tags_vn_bayesian tb
+ FROM tags_vn_stored tb
JOIN vn v ON v.id = tb.vid
JOIN vn_rev vr ON vr.id = v.latest
!W