From 151a8338c931389c6d67389c56c2d8862e882de6 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sat, 14 Nov 2009 18:46:59 +0100 Subject: SQL: Cached bayesian VN rating and vote counts Was a good idea after all... --- lib/VNDB/Handler/VNBrowse.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/VNDB/Handler') diff --git a/lib/VNDB/Handler/VNBrowse.pm b/lib/VNDB/Handler/VNBrowse.pm index 87f3371a..3aaa1e25 100644 --- a/lib/VNDB/Handler/VNBrowse.pm +++ b/lib/VNDB/Handler/VNBrowse.pm @@ -55,13 +55,21 @@ sub list { $f->{s} = 'title' if !@ti && $f->{s} eq 'tagscore'; $f->{o} = $f->{s} eq 'tagscore' ? 'd' : 'a' if !$f->{o}; + my $sortcol = {qw| + rel c_released + pop c_popularity + rating c_rating + title title + tagscore tagscore + |}->{$f->{s}}; + my($list, $np) = $self->dbVNGet( what => 'rating', $char ne 'all' ? ( char => $char ) : (), $f->{q} ? ( search => $f->{q} ) : (), results => 50, page => $f->{p}, - order => ($f->{s} eq 'rel' ? 'c_released' : $f->{s} eq 'pop' ? 'c_popularity' : $f->{s}).($f->{o} eq 'a' ? ' ASC' : ' DESC'), + order => $sortcol.($f->{o} eq 'a' ? ' ASC' : ' DESC'), $f->{pl}[0] ? ( platform => $f->{pl} ) : (), $f->{ln}[0] ? ( lang => $f->{ln} ) : (), @ti ? (tags_include => [ $f->{sp}, \@ti ]) : (), @@ -117,8 +125,8 @@ sub list { 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; + txt sprintf '%.2f', $l->{c_rating}; + b class => 'grayedout', sprintf ' (%d)', $l->{c_votecount}; end; end; }, -- cgit v1.2.3