diff --git a/roulette.py b/roulette.py index 9974744..4c692de 100644 --- a/roulette.py +++ b/roulette.py @@ -296,10 +296,31 @@ def banned(): else: explanation = u'Tu t\'es tranché toi-même, pas de chance...' + #Calcul des statistiques + con = connect_sqlite() + cur = con.cursor() + + cur.execute("""select firstname,name,ban_end from players""") + + rows = cur.fetchall() + con.close() + tranchés = 0 + n_tranchés = 0 + with open(IMMUNITY_FILE, 'r') as f: + immunity = f.read() + for row in rows: + if row[0]+' '+row[1] not in immunity: + if row[2] > time(): + tranchés += 1 + else: + n_tranchés += 1 + + stats = (tranchés,n_tranchés) + timeleft = int(player['ban_end'] - time()) return render_template('banned.html', \ - explanation=explanation, timeleft=timeleft) + explanation=explanation, timeleft=timeleft, stats=stats) @app.route('/banned_ip') @@ -367,6 +388,7 @@ def home(): bans_hist.append(entry) + #Calcul des statistiques con = connect_sqlite() cur = con.cursor()