summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-11-14 16:37:25 +0100
committerYorhel <git@yorhel.nl>2009-11-14 16:43:48 +0100
commited15643975e6e05ce5e8b9509901f769c86e06b4 (patch)
tree9cc857ca8217ce345d9b796217cd2858781c15ad /lib/VNDB/Handler
parentc7ff7086534cd9de7ce4043eb10c7161401c1b96 (diff)
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.
Diffstat (limited to 'lib/VNDB/Handler')
-rw-r--r--lib/VNDB/Handler/VNBrowse.pm8
1 files changed, 7 insertions, 1 deletions
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;
},
);