From 70a0245e8937f3ebcff85d949d0cf04e7a50aa10 Mon Sep 17 00:00:00 2001 From: wangxiyu191 <910741878@qq.com> Date: Thu, 28 Jul 2016 12:00:45 +0800 Subject: [PATCH] fix DetachedInstanceError on /admin/statistics (#133) see http://stackoverflow.com/questions/15397680/detaching-sqlalchemy-instance-so-no-refresh-happens --- CTFd/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CTFd/admin.py b/CTFd/admin.py index 4cd71c9..4f0675c 100644 --- a/CTFd/admin.py +++ b/CTFd/admin.py @@ -733,7 +733,8 @@ def admin_stats(): least_solved_chal = Challenges.query.add_columns(solves_cnt) \ .outerjoin(solves_sub, solves_sub.columns.chalid == Challenges.id) \ .order_by(solves_cnt.asc()).first() - + + db.session.expunge_all() db.session.commit() db.session.close()