[stats_prises] plus de chambres fictives au G
darcs-hash:20100930175051-ffbb2-7871f3e7958893fa39cdb1f4aea8ecadbc941844.gz
This commit is contained in:
parent
0f6ebda2c4
commit
63c7f6e737
1 changed files with 13 additions and 4 deletions
|
@ -21,19 +21,28 @@ def compte_prises(reseau, batiment=''):
|
|||
n = cur.fetchone()[0]
|
||||
else:
|
||||
batiment = batiment.lower()
|
||||
cur.execute("SELECT COUNT(prises) FROM prises WHERE (batiment, " + reseau + ")=(%s, True)", (batiment, ))
|
||||
if batiment == "g":
|
||||
cur.execute("SELECT COUNT(prises) FROM prises WHERE (batiment, " + reseau + ")=(%s, True) AND substring(chambre for 1) <> '0'", (batiment, ))
|
||||
else:
|
||||
cur.execute("SELECT COUNT(prises) FROM prises WHERE (batiment, " + reseau + ")=(%s, True)", (batiment, ))
|
||||
n = cur.fetchone()[0]
|
||||
|
||||
return n
|
||||
|
||||
tot_crans = 0
|
||||
tot_crous = 0
|
||||
|
||||
data = []
|
||||
for bat in ['A', 'B', 'C', 'G', 'H', 'I', 'J', 'M', '']:
|
||||
for bat in ['A', 'B', 'C', 'G', 'H', 'I', 'J', 'M']:
|
||||
n_crans = compte_prises('crans', bat)
|
||||
n_crous = compte_prises('crous', bat)
|
||||
tot_crans += n_crans
|
||||
tot_crous += n_crous
|
||||
frac_crans = 1.*n_crans/(n_crous + n_crans)
|
||||
if bat == '':
|
||||
bat = 'Total'
|
||||
data.append([bat, n_crans, n_crous, '%0.2f' % (100*frac_crans)])
|
||||
|
||||
data.append(["Total", tot_crans, tot_crous, '%0.2f' % (100.*n_crans/(n_crous+n_crans))])
|
||||
|
||||
print tableau(data, [u'Bât.', u'CRANS',
|
||||
u'CROUS', u'% CRANS'],
|
||||
[7, 7, 7, 9], ['c', 'd', 'd', 'd'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue