summaryrefslogtreecommitdiffstats
path: root/web/lib/stats.inc.php
diff options
context:
space:
mode:
authorcanyonknight <canyonknight@gmail.com>2013-02-03 16:26:29 +0000
committerLukas Fleischer <archlinux@cryptocrack.de>2013-02-10 12:10:38 +0100
commit8d6c872297459ceb463ed496968cc7cea32274a8 (patch)
tree2e1e5e07459f7ce62be0dccf26609bef4b2ad873 /web/lib/stats.inc.php
parent8e03e68d687015b5cd8c9d3857e1a1d007252afa (diff)
downloadaurweb-8d6c872297459ceb463ed496968cc7cea32274a8.tar.xz
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 <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/stats.inc.php')
-rw-r--r--web/lib/stats.inc.php28
1 files changed, 14 insertions, 14 deletions
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');
}