From ed15643975e6e05ce5e8b9509901f769c86e06b4 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sat, 14 Nov 2009 16:37:25 +0100 Subject: Added bayesian rating and vote count to the VN list It's even realtime! To my surprise this calculation isn't very heavy, or PostgreSQL is just extremely fast. The GetVN query on /v/all takes 100ms in the worst case (instead of the usual 30-60ms). Can always cache this later on. --- lib/VNDB/Handler/VNBrowse.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/VNDB/Handler/VNBrowse.pm') diff --git a/lib/VNDB/Handler/VNBrowse.pm b/lib/VNDB/Handler/VNBrowse.pm index bca21151..87f3371a 100644 --- a/lib/VNDB/Handler/VNBrowse.pm +++ b/lib/VNDB/Handler/VNBrowse.pm @@ -16,7 +16,7 @@ sub list { my($self, $char) = @_; my $f = $self->formValidate( - { name => 's', required => 0, default => 'tagscore', enum => [ qw|title rel pop tagscore| ] }, + { name => 's', required => 0, default => 'tagscore', enum => [ qw|title rel pop tagscore rating| ] }, { name => 'o', required => 0, enum => [ 'a','d' ] }, { name => 'p', required => 0, default => 1, template => 'int' }, { name => 'q', required => 0, default => '' }, @@ -56,6 +56,7 @@ sub list { $f->{o} = $f->{s} eq 'tagscore' ? 'd' : 'a' if !$f->{o}; my($list, $np) = $self->dbVNGet( + what => 'rating', $char ne 'all' ? ( char => $char ) : (), $f->{q} ? ( search => $f->{q} ) : (), results => 50, @@ -90,6 +91,7 @@ sub list { [ '', 0, undef, 'tc3' ], [ mt('_vnbrowse_col_released'), 'rel', undef, 'tc4' ], [ mt('_vnbrowse_col_popularity'), 'pop', undef, 'tc5' ], + [ mt('_vnbrowse_col_rating'), 'rating', undef, 'tc6' ], ], row => sub { my($s, $n, $l) = @_; @@ -114,6 +116,10 @@ sub list { lit $self->{l10n}->datestr($l->{c_released}); end; td class => 'tc5', sprintf '%.2f', $l->{c_popularity}*100; + td class => 'tc6'; + txt sprintf '%.2f', $l->{rating}||0; + b class => 'grayedout', sprintf ' (%d)', $l->{votecount}||0; + end; end; }, ); -- cgit v1.2.3