diff options
author | Yorhel <git@yorhel.nl> | 2009-03-08 12:37:32 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-03-08 12:37:32 +0100 |
commit | 351a48f316e5c25a2b6da03c5890c29db11f89ad (patch) | |
tree | 099e342ff7b84a1eaccfa9fc19993dbbd5e1cf41 /lib/VNDB/DB/Tags.pm | |
parent | bfd587563ae9fede8299bf97dfea1e07c2d4fefe (diff) |
(Kind-of) finalized the tag index
Couldn't think of anything more useful to display than simply all
tags without parents and a few of their subtags.
Diffstat (limited to 'lib/VNDB/DB/Tags.pm')
-rw-r--r-- | lib/VNDB/DB/Tags.pm | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm index a50e6d38..ff3e57be 100644 --- a/lib/VNDB/DB/Tags.pm +++ b/lib/VNDB/DB/Tags.pm @@ -5,7 +5,7 @@ use strict; use warnings; use Exporter 'import'; -our @EXPORT = qw|dbTagGet dbTagEdit dbTagAdd dbTagDel dbTagLinks dbTagLinkEdit dbTagStats dbTagVNs|; +our @EXPORT = qw|dbTagGet dbTagTree dbTagEdit dbTagAdd dbTagDel dbTagLinks dbTagLinkEdit dbTagStats dbTagVNs|; # %options->{ id name search page results order what } @@ -40,17 +40,24 @@ sub dbTagGet { ); if($o{what} =~ /parents\((\d+)\)/) { - $_->{parents} = $self->dbAll(q|SELECT lvl, tag, name, c_vns FROM tag_tree(?, ?, false)|, $_->{id}, $1) for (@$r); + $_->{parents} = $self->dbTagTree($_->{id}, $1, 0) for(@$r); } if($o{what} =~ /childs\((\d+)\)/) { - $_->{childs} = $self->dbAll(q|SELECT lvl, tag, name, c_vns FROM tag_tree(?, ?, true)|, $_->{id}, $1) for (@$r); + $_->{childs} = $self->dbTagTree($_->{id}, $1, 1) for(@$r); } return wantarray ? ($r, $np) : $r; } +# plain interface to the tag_tree() stored procedure in pgsql +sub dbTagTree { + my($self, $id, $lvl, $dir) = @_; + return $self->dbAll('SELECT * FROM tag_tree(?, ?, ?)', $id, $lvl||0, $dir?1:0); +} + + # args: tag id, %options->{ columns in the tags table + parents } sub dbTagEdit { my($self, $id, %o) = @_; |