From 8d6c872297459ceb463ed496968cc7cea32274a8 Mon Sep 17 00:00:00 2001 From: canyonknight Date: Sun, 3 Feb 2013 16:26:29 +0000 Subject: Remove unnecessary database connection parameter from all functions All functions now have a database connection method that will use the same database connection. This imitates the functionality of passing a database connection as an argument and makes it redundant. Signed-off-by: canyonknight Signed-off-by: Lukas Fleischer --- web/lib/stats.inc.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'web/lib/stats.inc.php') diff --git a/web/lib/stats.inc.php b/web/lib/stats.inc.php index cfae794..3b7cb8f 100644 --- a/web/lib/stats.inc.php +++ b/web/lib/stats.inc.php @@ -9,7 +9,8 @@ include_once('aur.inc.php'); * * @return void */ -function updates_table($dbh) { +function updates_table() { + $dbh = DB::connect(); $key = 'recent_updates'; if(!($newest_packages = get_cache_value($key))) { $q = 'SELECT * FROM Packages ORDER BY ModifiedTS DESC LIMIT 10'; @@ -32,16 +33,15 @@ function updates_table($dbh) { * * @return void */ -function user_table($userid, $dbh) { +function user_table($userid) { $base_q = "SELECT count(*) FROM Packages WHERE Packages.MaintainerUID = " . $userid; - $maintainer_unsupported_count = db_cache_value($base_q, $dbh, + $maintainer_unsupported_count = db_cache_value($base_q, 'user_unsupported_count:' . $userid); $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:' . $userid); + $flagged_outdated = db_cache_value($q, 'user_flagged_outdated:' . $userid); include('stats/user_table.php'); } @@ -53,34 +53,34 @@ function user_table($userid, $dbh) { * * @return void */ -function general_stats_table($dbh) { +function general_stats_table() { # AUR statistics $q = "SELECT count(*) FROM Packages"; - $unsupported_count = db_cache_value($q, $dbh, 'unsupported_count'); + $unsupported_count = db_cache_value($q, 'unsupported_count'); $q = "SELECT count(*) FROM Packages WHERE MaintainerUID IS NULL"; - $orphan_count = db_cache_value($q, $dbh, 'orphan_count'); + $orphan_count = db_cache_value($q, 'orphan_count'); $q = "SELECT count(*) FROM Users"; - $user_count = db_cache_value($q, $dbh, 'user_count'); + $user_count = db_cache_value($q, 'user_count'); $q = "SELECT count(*) FROM Users,AccountTypes WHERE Users.AccountTypeID = AccountTypes.ID AND AccountTypes.AccountType = 'Trusted User'"; - $tu_count = db_cache_value($q, $dbh, 'tu_count'); + $tu_count = db_cache_value($q, 'tu_count'); $targstamp = intval(strtotime("-7 days")); $yearstamp = intval(strtotime("-1 year")); $q = "SELECT count(*) FROM Packages WHERE Packages.ModifiedTS >= $targstamp AND Packages.ModifiedTS = Packages.SubmittedTS"; - $add_count = db_cache_value($q, $dbh, 'add_count'); + $add_count = db_cache_value($q, 'add_count'); $q = "SELECT count(*) FROM Packages WHERE Packages.ModifiedTS >= $targstamp AND Packages.ModifiedTS != Packages.SubmittedTS"; - $update_count = db_cache_value($q, $dbh, 'update_count'); + $update_count = db_cache_value($q, 'update_count'); $q = "SELECT count(*) FROM Packages WHERE Packages.ModifiedTS >= $yearstamp AND Packages.ModifiedTS != Packages.SubmittedTS"; - $update_year_count = db_cache_value($q, $dbh, 'update_year_count'); + $update_year_count = db_cache_value($q, 'update_year_count'); $q = "SELECT count(*) FROM Packages WHERE Packages.ModifiedTS = Packages.SubmittedTS"; - $never_update_count = db_cache_value($q, $dbh, 'never_update_count'); + $never_update_count = db_cache_value($q, 'never_update_count'); include('stats/general_stats_table.php'); } -- cgit v1.2.3-70-g09d2