MCPcopy Index your code
hub / github.com/ddserver/ddserver / get_statistics

Function get_statistics

ddserver/interface/pages/index.py:76–106  ·  view source on GitHub ↗
(user,
                   db)

Source from the content-addressed store, hash-verified

74@require(db = 'ddserver.db:Database')
75@authorized()
76def get_statistics(user,
77 db):
78 # get some statistics
79 with db.cursor() as cur:
80 cur.execute('''
81 SELECT COUNT(`id`) AS count
82 FROM `users`
83 ''')
84 users = cur.fetchone()
85
86 cur.execute('''
87 SELECT COUNT(`id`) AS count
88 FROM `suffixes`
89 ''')
90 zones = cur.fetchone()
91
92 cur.execute('''
93 SELECT COUNT(`id`) AS count
94 FROM `hosts`
95 ''')
96 hosts = cur.fetchone()
97
98
99 cur.execute('''
100 SELECT COUNT(`id`) AS count
101 FROM `hosts`
102 WHERE `user_id` = %(user_id)s
103 ''', {'user_id': user.id })
104 userhosts = cur.fetchone()
105
106 return (users, zones, hosts, userhosts)

Callers 1

get_indexFunction · 0.85

Calls 1

cursorMethod · 0.80

Tested by

no test coverage detected