diff options
Diffstat (limited to 'update-stats.py')
-rwxr-xr-x | update-stats.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/update-stats.py b/update-stats.py new file mode 100755 index 0000000..863b3a6 --- /dev/null +++ b/update-stats.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import common +from Mailman import mm_cfg +import MySQLdb + +def main(): + conn = MySQLdb.connect (host = mm_cfg.MYSQL_MEMBER_DB_HOST, + user = mm_cfg.MYSQL_MEMBER_DB_USER, + passwd = mm_cfg.MYSQL_MEMBER_DB_PASS, + db = mm_cfg.MYSQL_MEMBER_DB_NAME) + cursor = conn.cursor() + cursor.execute (""" + UPDATE stats + SET value = ( + SELECT COUNT(DISTINCT listname) + FROM lists) + WHERE `key` = 'LISTS'; + """) + + cursor.execute (""" + UPDATE stats + SET value = ( + SELECT COUNT(*) + FROM lists) + WHERE `key` = 'SUBSCRIBTIONS'; + """) + + cursor.execute (""" + UPDATE stats + SET value = ( + SELECT COUNT(DISTINCT address) + FROM lists) + WHERE `key` = 'ADDRESSES'; + """) + + cursor.close() + conn.commit() + conn.close() + +if __name__ == '__main__': + main() |