summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-11-14 18:46:59 +0100
committerYorhel <git@yorhel.nl>2009-11-14 18:46:59 +0100
commit151a8338c931389c6d67389c56c2d8862e882de6 (patch)
tree3f5c8c691f92005324c5c2cd965a4a0d04c4fcd1 /lib/VNDB/Handler
parent2394a77e8d503ebcf78109ced76680e46770b617 (diff)
SQL: Cached bayesian VN rating and vote counts
Was a good idea after all...
Diffstat (limited to 'lib/VNDB/Handler')
-rw-r--r--lib/VNDB/Handler/VNBrowse.pm14
1 files changed, 11 insertions, 3 deletions
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;
},