From f4fec18f4467a2f60061ecd81ec0b6ed43d9a564 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Tue, 25 Oct 2016 22:41:31 -0400 Subject: [PATCH] Handling situation with no solves --- CTFd/admin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CTFd/admin.py b/CTFd/admin.py index ea4e860..f00e674 100644 --- a/CTFd/admin.py +++ b/CTFd/admin.py @@ -740,8 +740,11 @@ def admin_stats(): for chal, count, name in solves: solve_data[name] = count - most_solved = max(solve_data, key=solve_data.get) - least_solved = min(solve_data, key=solve_data.get) + most_solved = None + least_solved = None + if len(solve_data): + most_solved = max(solve_data, key=solve_data.get) + least_solved = min(solve_data, key=solve_data.get) db.session.expunge_all() db.session.commit()