summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2011-01-03 20:36:39 +0100
committerYorhel <git@yorhel.nl>2011-01-03 21:35:40 +0100
commitdf6dc445df2f73381829b8af8db606cea67f589d (patch)
tree7e88dbf3d20420b08791371c33578496a7e59fc4 /lib
parent5894b1f62abbe8837067bdf34a559d78e0a5f3a5 (diff)
SQL: Added tags_vn.ignore column and updated queries to respect this
This is the first step in adding support for overruling tag votes by moderators. Also removed some unused options from dbTagStats(); the tag-vote-stats-by-user pages have been removed in the previous VNDB update, which was the only page using these additional options.
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/Tags.pm39
1 files changed, 5 insertions, 34 deletions
diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm
index b3e16960..93705de0 100644
--- a/lib/VNDB/DB/Tags.pm
+++ b/lib/VNDB/DB/Tags.pm
@@ -235,26 +235,16 @@ sub dbTagLinkEdit {
}
-# Fetch all tags related to a VN or User
-# Argument: %options->{ uid vid minrating results what page sort reverse }
-# what: vns
-# sort: name, count, rating
+# Fetch all tags related to a VN
+# Argument: %options->{ vid minrating results what page sort reverse }
+# sort: name, rating
sub dbTagStats {
my($self, %o) = @_;
$o{results} ||= 10;
$o{page} ||= 1;
- $o{what} ||= '';
-
- my %where = (
- $o{uid} ? (
- 'tv.uid = ?' => $o{uid} ) : (),
- $o{vid} ? (
- 'tv.vid = ?' => $o{vid} ) : (),
- );
my $order = sprintf {
name => 't.name %s',
- count => 'count(*) %s',
rating => 'avg(tv.vote) %s',
}->{ $o{sort}||'name' }, $o{reverse} ? 'DESC' : 'ASC';
@@ -262,32 +252,13 @@ sub dbTagStats {
SELECT t.id, t.name, count(*) as cnt, avg(tv.vote) as rating, COALESCE(avg(tv.spoiler), 0) as spoiler
FROM tags t
JOIN tags_vn tv ON tv.tag = t.id
- !W
+ WHERE tv.vid = ? AND NOT tv.ignore
GROUP BY t.id, t.name
!s
ORDER BY !s|,
- \%where, defined $o{minrating} ? "HAVING avg(tv.vote) > $o{minrating}" : '',
- $order
+ $o{vid}, defined $o{minrating} ? "HAVING avg(tv.vote) > $o{minrating}" : '', $order
);
- if(@$r && $o{what} =~ /vns/ && $o{uid}) {
- my %r = map {
- $_->{vns} = [];
- ($_->{id}, $_->{vns})
- } @$r;
-
- push @{$r{$_->{tag}}}, $_ for (@{$self->dbAll(q|
- SELECT tv.tag, tv.vote, tv.spoiler, vr.vid, vr.title, vr.original
- FROM tags_vn tv
- JOIN vn v ON v.id = tv.vid
- JOIN vn_rev vr ON vr.id = v.latest
- WHERE tv.uid = ?
- AND tv.tag IN(!l)
- ORDER BY vr.title ASC|,
- $o{uid}, [ keys %r ]
- )});
- }
-
return wantarray ? ($r, $np) : $r;
}