aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorVikraman Choudhury <vikraman.choudhury@gmail.com>2011-07-09 22:39:25 +0530
committerVikraman Choudhury <vikraman.choudhury@gmail.com>2011-07-09 22:39:25 +0530
commit304488f520ecbcea352283a9b5c0c3c41ddf05b5 (patch)
tree79a5b22c01f5b2c99dc528e95e7a7b21a962dfc5 /server
parentadded a mysql dump of test database (diff)
downloadgentoostats-304488f520ecbcea352283a9b5c0c3c41ddf05b5.tar.gz
gentoostats-304488f520ecbcea352283a9b5c0c3c41ddf05b5.tar.bz2
gentoostats-304488f520ecbcea352283a9b5c0c3c41ddf05b5.zip
per useflag stats
Diffstat (limited to 'server')
-rwxr-xr-xserver/app.py3
-rw-r--r--server/templates/use.html11
-rw-r--r--server/templates/use_useflag.html8
-rw-r--r--server/use.py48
4 files changed, 54 insertions, 16 deletions
diff --git a/server/app.py b/server/app.py
index 94dffdd..fa5d6a4 100755
--- a/server/app.py
+++ b/server/app.py
@@ -22,12 +22,13 @@ urls = (
r'/mirror', 'Mirror',
r'/feature', 'Feature',
r'/keyword', 'Keyword',
- r'/use', 'Use',
r'/repo', 'Repo',
r'/lang', 'Lang',
r'/package/(.+)/(.+)', 'Package',
r'/package/(.+)', 'Package',
r'/package', 'Package',
+ r'/use/(.+)', 'Use',
+ r'/use', 'Use',
r'/host/(.+)', 'Host'
)
diff --git a/server/templates/use.html b/server/templates/use.html
index 209f8f8..bd2a3f7 100644
--- a/server/templates/use.html
+++ b/server/templates/use.html
@@ -1,11 +1,4 @@
$def with (use_data)
-$var title: Use
+$var title: Useflags
-<table border="1">
- <tr>
- <th>Use</th>
- <th>Hosts</th>
- </tr>
- $for use in use_data.keys():
- <tr><td>$use</td><td>$use_data[use]['HOSTS']</td></tr>
-</table>
+No. of useflags: $use_data['USE_COUNT']
diff --git a/server/templates/use_useflag.html b/server/templates/use_useflag.html
new file mode 100644
index 0000000..4d27b4a
--- /dev/null
+++ b/server/templates/use_useflag.html
@@ -0,0 +1,8 @@
+$def with (useflag, use_data)
+$var title: Useflags
+
+Useflag: $useflag</br>
+Globally enabled: $use_data['GLOBAL_COUNT'] hosts</br>
+Enabled: $use_data['PLUS_COUNT'] packages</br>
+Disabled: $use_data['MINUS_COUNT'] packages</br>
+Unset: $use_data['UNSET_COUNT'] packages</br>
diff --git a/server/use.py b/server/use.py
index dfdcfaf..5b7a54d 100644
--- a/server/use.py
+++ b/server/use.py
@@ -2,9 +2,45 @@
from config import render, db
class Use(object):
- def GET(self):
- use_count = db.query('SELECT USEFLAG,COUNT(UUID) AS HOSTS FROM GLOBAL_USEFLAGS NATURAL JOIN USEFLAGS GROUP BY USEFLAG')
- use_data = dict()
- for t in use_count:
- use_data[t['USEFLAG']] = {'HOSTS':t['HOSTS']}
- return render.use(use_data)
+ def GET(self, *args):
+ l = len(args)
+ if l == 0:
+ use_query = db.query('SELECT COUNT(DISTINCT UKEY) AS USE_COUNT FROM USEFLAGS')
+ use_tuple = use_query[0]
+ use_data = {'USE_COUNT':use_tuple['USE_COUNT']}
+ return render.use(use_data)
+
+ elif l == 1:
+ global_use_query = db.query('SELECT COUNT(DISTINCT UUID) AS GLOBAL_COUNT\
+ FROM GLOBAL_USEFLAGS RIGHT OUTER JOIN USEFLAGS\
+ ON GLOBAL_USEFLAGS.UKEY = USEFLAGS.UKEY\
+ WHERE USEFLAG=$useflag', vars={'useflag':args[0]})
+ plus_use_query = db.query('SELECT COUNT(DISTINCT IPKEY) AS PLUS_COUNT\
+ FROM PLUS_USEFLAGS RIGHT OUTER JOIN USEFLAGS\
+ ON PLUS_USEFLAGS.UKEY = USEFLAGS.UKEY\
+ WHERE USEFLAG=$useflag', vars={'useflag':args[0]})
+ minus_use_query = db.query('SELECT COUNT(DISTINCT IPKEY) AS MINUS_COUNT\
+ FROM MINUS_USEFLAGS RIGHT OUTER JOIN USEFLAGS\
+ ON MINUS_USEFLAGS.UKEY = USEFLAGS.UKEY\
+ WHERE USEFLAG=$useflag', vars={'useflag':args[0]})
+ unset_use_query = db.query('SELECT COUNT(DISTINCT IPKEY) AS UNSET_COUNT\
+ FROM UNSET_USEFLAGS RIGHT OUTER JOIN USEFLAGS\
+ ON UNSET_USEFLAGS.UKEY = USEFLAGS.UKEY\
+ WHERE USEFLAG=$useflag', vars={'useflag':args[0]})
+
+ global_use_tuple = global_use_query[0]
+ plus_use_tuple = plus_use_query[0]
+ minus_use_tuple = minus_use_query[0]
+ unset_use_tuple = unset_use_query[0]
+
+ use_data = {
+ 'GLOBAL_COUNT':global_use_tuple['GLOBAL_COUNT'],
+ 'PLUS_COUNT':plus_use_tuple['PLUS_COUNT'],
+ 'MINUS_COUNT':minus_use_tuple['MINUS_COUNT'],
+ 'UNSET_COUNT':unset_use_tuple['UNSET_COUNT']
+ }
+
+ return render.use_useflag(args[0], use_data)
+
+ else:
+ return config.internalerror()