summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/Discussions.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-01-11 09:55:01 +0100
committerYorhel <git@yorhel.nl>2010-01-11 09:55:01 +0100
commit947b849b6bb6e927abfb2617f1139abaea3f071e (patch)
treef873635bb6d37d2bc629b8a0f0013c3d6e38fa0a /lib/VNDB/DB/Discussions.pm
parent322da93cc2e3dbba9fde39f9a42268f582c0d0fe (diff)
Fixed sorting bug on /u+/posts
Damn, so many bugs... This one was introduced in 9613533da2c58af3c64e3bd4ed7b92b22ffd442f
Diffstat (limited to 'lib/VNDB/DB/Discussions.pm')
-rw-r--r--lib/VNDB/DB/Discussions.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm
index deeb7480..1c27c22e 100644
--- a/lib/VNDB/DB/Discussions.pm
+++ b/lib/VNDB/DB/Discussions.pm
@@ -158,7 +158,7 @@ sub dbThreadCount {
}
-# Options: tid, num, what, uid, mindate, hide, page, results
+# Options: tid, num, what, uid, mindate, hide, page, results, sort, reverse
# what: user thread
sub dbPostGet {
my($self, %o) = @_;
@@ -191,13 +191,18 @@ sub dbPostGet {
$o{what} =~ /thread/ ? 'JOIN threads t ON t.id = tp.tid' : (),
);
+ my $order = sprintf {
+ num => 'tp.num %s',
+ date => 'tp.date %s',
+ }->{ $o{sort}||'num' }, $o{reverse} ? 'DESC' : 'ASC';
+
my($r, $np) = $self->dbPage(\%o, q|
SELECT !s
FROM threads_posts tp
!s
!W
- ORDER BY tp.num ASC|,
- join(', ', @select), join(' ', @join), \%where
+ ORDER BY !s|,
+ join(', ', @select), join(' ', @join), \%where, $order
);
return wantarray ? ($r, $np) : $r;