summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/Users.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2008-12-11 17:09:18 +0100
committerYorhel <git@yorhel.nl>2008-12-11 17:09:18 +0100
commitb03787002a5065a33d51bfac3d5d87787d23fd79 (patch)
tree847304408e0bb0214fc879912621cdd08640f526 /lib/VNDB/DB/Users.pm
parent739327d3d50b7cae9f9cb938fa25129ae34e78cb (diff)
Forum & list stats to user pages
They're relatively cheap on server resources and easy to create, so why not?
Diffstat (limited to 'lib/VNDB/DB/Users.pm')
-rw-r--r--lib/VNDB/DB/Users.pm19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/VNDB/DB/Users.pm b/lib/VNDB/DB/Users.pm
index 060f8b26..501bb8bb 100644
--- a/lib/VNDB/DB/Users.pm
+++ b/lib/VNDB/DB/Users.pm
@@ -8,13 +8,15 @@ use Exporter 'import';
our @EXPORT = qw|dbUserGet dbUserEdit dbUserAdd dbUserDel|;
-# %options->{ username passwd mail order uid results page }
+# %options->{ username passwd mail order uid results page what }
+# what: stats
sub dbUserGet {
my $s = shift;
my %o = (
order => 'username ASC',
page => 1,
results => 10,
+ what => '',
@_
);
@@ -35,13 +37,22 @@ sub dbUserGet {
'id > 0' => 1 ) : (),
);
+ my @select = (
+ 'u.*',
+ $o{what} =~ /stats/ ? (
+ '(SELECT COUNT(*) FROM rlists WHERE uid = u.id) AS releasecount',
+ '(SELECT COUNT(DISTINCT rv.vid) FROM rlists rl JOIN releases r ON rl.rid = r.id JOIN releases_vn rv ON rv.rid = r.latest WHERE uid = u.id) AS vncount',
+ '(SELECT COUNT(*) FROM threads_posts WHERE uid = u.id) AS postcount',
+ '(SELECT COUNT(*) FROM threads_posts WHERE uid = u.id AND num = 1) AS threadcount',
+ ) : (),
+ );
+
my($r, $np) = $s->dbPage(\%o, q|
- SELECT *
+ SELECT !s
FROM users u
!W
ORDER BY !s|,
- \%where,
- $o{order}
+ join(', ', @select), \%where, $o{order}
);
return wantarray ? ($r, $np) : $r;
}