diff options
author | Yorhel <git@yorhel.nl> | 2009-11-27 14:48:20 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-11-27 14:52:20 +0100 |
commit | 9613533da2c58af3c64e3bd4ed7b92b22ffd442f (patch) | |
tree | 425ee689a98a555638431f92d1bc76cbef22eedd /lib/VNDB/Handler/Misc.pm | |
parent | 542c1e22daf2648b3babce2ab2050120eec0a9b9 (diff) |
DB: Abstracted all ORDER BY clauses in the DB abstraction layer
The ORDER BY was previously specified using an 'order' argument, which
would then be directly inserted into the query. The new method is the
same as what I used for the public API: two 'sort' and 'reverse'
arguments. This should be less error-prone and more readable.
This changes quite a lot of code, so I hope I haven't forgotten to
update something along the way.
Diffstat (limited to 'lib/VNDB/Handler/Misc.pm')
-rw-r--r-- | lib/VNDB/Handler/Misc.pm | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm index dbb348be..e762df8f 100644 --- a/lib/VNDB/Handler/Misc.pm +++ b/lib/VNDB/Handler/Misc.pm @@ -78,7 +78,7 @@ sub homepage { # Announcements td; - my $an = $self->dbThreadGet(type => 'an', order => 't.id DESC', results => 2); + my $an = $self->dbThreadGet(type => 'an', sort => 'id', reverse => 1, results => 2); h1; a href => '/t/an', mt '_home_announcements'; end; @@ -98,7 +98,7 @@ sub homepage { h1; a href => '/t', mt '_home_recentposts'; end; - my $posts = $self->dbThreadGet(what => 'lastpost boardtitles', results => 10, order => 'tpl.date DESC', notusers => 1); + my $posts = $self->dbThreadGet(what => 'lastpost boardtitles', results => 10, sort => 'lastpost', reverse => 1, notusers => 1); ul; for (@$posts) { my $boards = join ', ', map mt("_dboard_$_->{type}").($_->{iid}?' > '.$_->{title}:''), @{$_->{boards}}; @@ -120,7 +120,7 @@ sub homepage { h1; a href => '/v/rand', mt '_home_randomvn'; end; - my $random = $self->dbVNGet(results => 10, order => 'RANDOM()'); + my $random = $self->dbVNGet(results => 10, sort => 'rand'); ul; for (@$random) { li; @@ -154,7 +154,7 @@ sub homepage { h1; a href => strftime('/r?ma=%Y%m%d;o=d;s=released', gmtime), mt '_home_justreleased'; end; - my $justrel = $self->dbReleaseGet(results => 10, order => 'rr.released DESC', unreleased => 0, what => 'platforms'); + my $justrel = $self->dbReleaseGet(results => 10, sort => 'released', reverse => 1, unreleased => 0, what => 'platforms'); ul; for (@$justrel) { li; @@ -300,7 +300,7 @@ sub docpage { $ii; }eg; s{^:TOP5CONTRIB:$}{ - my $l = $self->dbUserGet(results => 6, order => 'c_changes DESC'); + my $l = $self->dbUserGet(results => 6, sort => 'changes', reverse => 1); '<dl>'.join('', map $_->{id} == 1 ? () : sprintf('<dt><a href="/u%d">%s</a></dt><dd>%d</dd>', $_->{id}, $_->{username}, $_->{c_changes}), @$l).'</dl>'; |