summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/ULists.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-12-10 11:57:47 +0100
committerYorhel <git@yorhel.nl>2010-12-10 11:57:47 +0100
commit5c949ff5cb57fc56e05dde010cc852f0f1207ca0 (patch)
tree74f064e785a66b20f742896ebd7a2bc4436f2dbd /lib/VNDB/DB/ULists.pm
parent3362cf0391fad05a0eed1bd11a54f4c97f5260db (diff)
Added vote listings for VNs and users (/[uv]+/votes)
Diffstat (limited to 'lib/VNDB/DB/ULists.pm')
-rw-r--r--lib/VNDB/DB/ULists.pm15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/VNDB/DB/ULists.pm b/lib/VNDB/DB/ULists.pm
index e926bae4..e52cbf37 100644
--- a/lib/VNDB/DB/ULists.pm
+++ b/lib/VNDB/DB/ULists.pm
@@ -147,13 +147,15 @@ sub dbVNListDel {
}
-# %options->{ uid vid hide results page what }
+# Options: uid vid hide hide_ign results page what sort reverse
# what: user, vn
sub dbVoteGet {
my($self, %o) = @_;
$o{results} ||= 50;
$o{page} ||= 1;
$o{what} ||= '';
+ $o{sort} ||= 'date';
+ $o{reverse} //= 1;
my %where = (
$o{uid} ? ( 'n.uid = ?' => $o{uid} ) : (),
@@ -178,13 +180,20 @@ sub dbVoteGet {
) : (),
);
+ my $order = sprintf {
+ date => 'n.date %s',
+ username => 'u.username %s',
+ title => 'vr.title %s',
+ vote => 'n.vote %s',
+ }->{$o{sort}}, $o{reverse} ? 'DESC' : 'ASC';
+
my($r, $np) = $self->dbPage(\%o, q|
SELECT !s
FROM votes n
!s
!W
- ORDER BY n.date DESC|,
- join(',', @select), join(' ', @join), \%where
+ ORDER BY !s|,
+ join(',', @select), join(' ', @join), \%where, $order
);
return wantarray ? ($r, $np) : $r;