diff options
author | Dan McGee <dan@archlinux.org> | 2012-05-02 16:14:01 -0500 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2012-05-06 12:12:51 +0200 |
commit | 97085daadcbc8b1ae1a01cd777605f66464a02ea (patch) | |
tree | b63f16334168cd3024897cdcb4a52a648b70985d /web/lib/stats.inc.php | |
parent | e9d8e9b8c074421d15103fd66112dea78800e72a (diff) | |
download | aurweb-97085daadcbc8b1ae1a01cd777605f66464a02ea.tar.xz |
user_table optimization
Rather than looking up by username, it makes more sense to look the
stats up by user ID to reduce the number of needed joins.
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/stats.inc.php')
-rw-r--r-- | web/lib/stats.inc.php | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/web/lib/stats.inc.php b/web/lib/stats.inc.php index 01e6700..2828dc9 100644 --- a/web/lib/stats.inc.php +++ b/web/lib/stats.inc.php @@ -17,17 +17,16 @@ function updates_table($dbh) { include('stats/updates_table.php'); } -function user_table($user, $dbh) { - $escuser = db_escape_string($user); - $base_q = "SELECT count(*) FROM Packages,Users WHERE Packages.MaintainerUID = Users.ID AND Users.Username='" . $escuser . "'"; +function user_table($userid, $dbh) { + $base_q = "SELECT count(*) FROM Packages WHERE Packages.MaintainerUID = " . $userid; $maintainer_unsupported_count = db_cache_value($base_q, $dbh, - 'user_unsupported_count:' . $escuser); + 'user_unsupported_count:' . $userid); - $q = "SELECT count(*) FROM Packages,Users WHERE Packages.OutOfDateTS IS NOT NULL AND Packages.MaintainerUID = Users.ID AND Users.Username='" . $escuser . "'"; + $q = "SELECT count(*) FROM Packages WHERE Packages.OutOfDateTS IS NOT NULL AND Packages.MaintainerUID = " . $userid; $flagged_outdated = db_cache_value($q, $dbh, - 'user_flagged_outdated:' . $escuser); + 'user_flagged_outdated:' . $userid); # If the user is a TU calculate the number of the packages $atype = account_from_sid($_COOKIE["AURSID"]); |