diff options
author | Yorhel <git@yorhel.nl> | 2019-06-26 12:55:02 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-06-26 12:55:44 +0200 |
commit | 8972da44acdc5fa4e053f32a184430fb0bdf9e80 (patch) | |
tree | 5ef1921bcd818b65823d505120c1f04feebd4547 /lib/VNDB/DB/Tags.pm | |
parent | 5d98346cb7163557c55ff2c850a6362edb9772ba (diff) |
VNPage: Don't show deleted/unapproved tags in tag cloud
The previous code would assume that these tags did not have any votes,
but that assumption doesn't necessarily hold anymore.
Diffstat (limited to 'lib/VNDB/DB/Tags.pm')
-rw-r--r-- | lib/VNDB/DB/Tags.pm | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm index 389e172a..dc542ff8 100644 --- a/lib/VNDB/DB/Tags.pm +++ b/lib/VNDB/DB/Tags.pm @@ -241,7 +241,7 @@ sub dbTagLinkEdit { # Fetch all tags related to a VN -# Argument: %options->{ vid minrating results what page sort reverse } +# Argument: %options->{ vid minrating state results what page sort reverse } # sort: name, rating sub dbTagStats { my($self, %o) = @_; @@ -254,17 +254,22 @@ sub dbTagStats { rating => "$rating %s", }->{ $o{sort}||'name' }, $o{reverse} ? 'DESC' : 'ASC'; + my %where = ( + 'tv.vid = ?' => $o{vid}, + defined $o{state} ? ('t.state = ?', $o{state}) : (), + ); + my($r, $np) = $self->dbPage(\%o, qq| SELECT t.id, t.name, t.cat, count(*) as cnt, $rating as rating, COALESCE(avg(CASE WHEN tv.ignore THEN NULL ELSE tv.spoiler END), t.defaultspoil) as spoiler, bool_or(tv.ignore) AS overruled FROM tags t JOIN tags_vn tv ON tv.tag = t.id - WHERE tv.vid = ? + !W GROUP BY t.id, t.name, t.cat !s ORDER BY !s|, - $o{vid}, defined $o{minrating} ? "HAVING $rating > $o{minrating}" : '', $order + \%where, defined $o{minrating} ? "HAVING $rating > $o{minrating}" : '', $order ); return wantarray ? ($r, $np) : $r; |