1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package VNDB::DB::Users;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT = qw|
dbUserGet
|;
# %options->{ uid results page what }
# sort: username registered votes changes tags
sub dbUserGet {
my $s = shift;
my %o = (
page => 1,
results => 10,
what => '',
@_
);
my %where = (
$o{uid} && !ref($o{uid}) ? (
'id = ?' => $o{uid} ) : (),
$o{uid} && ref($o{uid}) ? (
'id IN(!l)' => [ $o{uid} ]) : (),
);
my @select = (
qw|id username c_votes c_changes c_tags|,
VNWeb::DB::sql_user(), # XXX: This duplicates id and username, but updating all the code isn't going to be easy
q|extract('epoch' from registered) as registered|,
);
my($r, $np) = $s->dbPage(\%o, q|
SELECT !s
FROM users u
!W
ORDER BY id DESC|,
join(', ', @select), \%where
);
return wantarray ? ($r, $np) : $r;
}
1;
|