Commit 97085daa authored by Dan McGee's avatar Dan McGee Committed by Lukas Fleischer
Browse files

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: default avatarDan McGee <dan@archlinux.org>
Signed-off-by: default avatarLukas Fleischer <archlinux@cryptocrack.de>
parent e9d8e9b8
......@@ -58,8 +58,8 @@ echo __(
<td class='boxSoft' valign='top'>
<?php
if (!empty($_COOKIE["AURSID"])) {
$user = username_from_sid($_COOKIE["AURSID"]);
user_table($user, $dbh);
$userid = uid_from_sid($_COOKIE["AURSID"]);
user_table($userid, $dbh);
echo '<br />';
}
......
......@@ -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"]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment