diff options
author | Loui Chang <louipc.ist@gmail.com> | 2008-11-04 03:52:07 +0100 |
---|---|---|
committer | Loui Chang <louipc.ist@gmail.com> | 2008-11-04 03:52:07 +0100 |
commit | a6147ab5ab297728adefdb97aaeedc93114b896d (patch) | |
tree | 49b508439ab2aa0cf4bd039d3b2d2d53e8860df0 /web/lib/stats.inc | |
parent | c85dfacc747387b9be6c53b4518ac680b505e0f7 (diff) | |
parent | 100451a9665cb387eeae2cb06cc22870cfd57c82 (diff) | |
download | aur-a6147ab5ab297728adefdb97aaeedc93114b896d.tar.gz aur-a6147ab5ab297728adefdb97aaeedc93114b896d.tar.xz |
Merge branch 'testing'
Conflicts:
web/html/pkgsubmit.php
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Diffstat (limited to 'web/lib/stats.inc')
-rw-r--r-- | web/lib/stats.inc | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/web/lib/stats.inc b/web/lib/stats.inc new file mode 100644 index 00000000..6fbc0334 --- /dev/null +++ b/web/lib/stats.inc @@ -0,0 +1,72 @@ +<?php + +include_once('aur.inc'); + +function updates_table($dbh) +{ + $q = 'SELECT * FROM Packages WHERE DummyPkg != 1 ORDER BY GREATEST(SubmittedTS,ModifiedTS) DESC LIMIT 0 , 10'; + $newest_packages = db_query($q, $dbh); + include('stats/updates_table.php'); +} + +function user_table($user, $dbh) +{ + + $base_q = 'SELECT count(*) FROM Packages,PackageLocations,Users WHERE Packages.MaintainerUID = Users.ID AND Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = "%s" AND Users.Username="' . + mysql_real_escape_string($user).'"'; + + $result = db_query(sprintf($base_q, 'unsupported'), $dbh); + $row = mysql_fetch_row($result); + $maintainer_unsupported_count = $row[0]; + + $q = "SELECT count(*) FROM Packages,Users WHERE Packages.OutOfDate = 1 AND Packages.MaintainerUID = Users.ID AND Users.Username='" . + mysql_real_escape_string($user)."'"; + + $result = db_query($q, $dbh); + $row = mysql_fetch_row($result); + $flagged_outdated = $row[0]; + + # If the user is a TU calculate the number of the packages + $atype = account_from_sid($_COOKIE["AURSID"]); + + if (($atype == 'Trusted User') || ($atype == 'Developer')) { + $result = db_query(sprintf($base_q, 'community'), $dbh); + $row = mysql_fetch_row($result); + $maintainer_community_count = $row[0]; + } + + include('stats/user_table.php'); +} + +function general_stats_table($dbh) +{ + # AUR statistics + $q = "SELECT count(*) FROM Packages,PackageLocations WHERE Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'unsupported'"; + $result = db_query($q, $dbh); + $row = mysql_fetch_row($result); + $unsupported_count = $row[0]; + + $q = "SELECT count(*) FROM Packages,PackageLocations WHERE Packages.LocationID = PackageLocations.ID AND PackageLocations.Location = 'community'"; + $result = db_query($q, $dbh); + $row = mysql_fetch_row($result); + $community_count = $row[0]; + + $q = "SELECT count(*) from Users"; + $result = db_query($q, $dbh); + $row = mysql_fetch_row($result); + $user_count = $row[0]; + + $q = "SELECT count(*) from Users,AccountTypes WHERE Users.AccountTypeID = AccountTypes.ID AND AccountTypes.AccountType = 'Trusted User'"; + $result = db_query($q, $dbh); + $row = mysql_fetch_row($result); + $tu_count = $row[0]; + + $targstamp = intval(strtotime("-7 days")); + $q = "SELECT count(*) from Packages WHERE (Packages.SubmittedTS >= $targstamp OR Packages.ModifiedTS >= $targstamp)"; + $result = db_query($q, $dbh); + $row = mysql_fetch_row($result); + $update_count = $row[0]; + + include('stats/general_stats_table.php'); +} + |