diff options
author | Yorhel <git@yorhel.nl> | 2019-12-22 16:24:58 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-12-22 16:29:10 +0100 |
commit | cd5e4dffdf4d99cac7d47433981cfa6d669b2b45 (patch) | |
tree | dc1f7ee0df86a6f3e38807b07bb1b0de2cd987c6 /lib/VNDB/Util/CommonHTML.pm | |
parent | 1b47e52e88d90478ff39744732085924fe5a51f2 (diff) |
ulist: Use new lists for VN vote stats & listing
To my surprise, I actually managed to achieve acceptable performance by
just adding two indices. I totally expected I'd have to keep a cache
column in ulist_vns whether the row is private or not. The partial index
on the users table in fact improves the performance of the vote graph
query. A covering index improves that even further, but that requires
Postgres 11+, which the Docker image doesn't have yet (and isn't all
that crucial anyway).
There's a rather annoying potential for confusion regarding the private
flag on votes. The user page & list stats only look at whether the
'Voted' label is private, whereas the VN stats use the "proper" approach
of checking for any public label. Not entirely sure which of the two is
more intuitive.
Diffstat (limited to 'lib/VNDB/Util/CommonHTML.pm')
-rw-r--r-- | lib/VNDB/Util/CommonHTML.pm | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm index 9472f53d..7a3d554c 100644 --- a/lib/VNDB/Util/CommonHTML.pm +++ b/lib/VNDB/Util/CommonHTML.pm @@ -215,6 +215,7 @@ sub htmlItemMessage { # generates two tables, one with a vote graph, other with recent votes +# Only supports $type eq 'v' now. sub htmlVoteStats { my($self, $type, $obj, $stats) = @_; @@ -244,12 +245,17 @@ sub htmlVoteStats { } end 'table'; - my $recent = $self->dbVoteGet( - $type.'id' => $obj->{id}, - results => 8, - what => $type eq 'v' ? 'user hide_list' : 'vn', - hide_ign => $type eq 'v', + my $recent = $self->dbAlli(' + SELECT uv.vote,', VNWeb::DB::sql_totime('uv.vote_date '), 'as date, ', VNWeb::DB::sql_user(), ' + , NOT EXISTS(SELECT 1 FROM ulist_vns_labels uvl JOIN ulist_labels ul ON ul.uid = uvl.uid AND ul.id = uvl.lbl WHERE uvl.uid = uv.uid AND uvl.vid = uv.vid AND NOT ul.private) AS hide_list + FROM ulist_vns uv + JOIN users u ON u.id = uv.uid + WHERE uv.vid =', \$obj->{id}, 'AND uv.vote IS NOT NULL + AND NOT EXISTS(SELECT 1 FROM users u WHERE u.id = uv.uid AND u.ign_votes) + ORDER BY uv.vote_date DESC + LIMIT', \8 ); + if(@$recent) { table class => 'recentvotes stripe'; thead; Tr; @@ -265,9 +271,7 @@ sub htmlVoteStats { for (@$recent) { Tr; td; - if($type eq 'u') { - a href => "/v$_->{vid}", title => $_->{original}||$_->{title}, shorten $_->{title}, 40; - } elsif($_->{hide_list}) { + if($_->{hide_list}) { b class => 'grayedout', 'hidden'; } else { VNWeb::HTML::user_($_); |