From 774f0ff1e17c8cbb3253441b9779cf99b37a7e8b Mon Sep 17 00:00:00 2001 From: guimoz Date: Mon, 30 Jan 2017 02:28:45 +0100 Subject: [PATCH] =?UTF-8?q?Graphe=20=C3=A9galement=20pr=C3=A9sent=20pour?= =?UTF-8?q?=20les=20ban?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roulette.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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()