diff --git a/CTFd/admin.py b/CTFd/admin.py index a4f532a4..06890d5e 100644 --- a/CTFd/admin.py +++ b/CTFd/admin.py @@ -438,7 +438,7 @@ def init_admin(app): solve_count = db.session.query(db.func.count(Solves.id)).first()[0] challenge_count = db.session.query(db.func.count(Challenges.id)).first()[0] most_solved_chal = Solves.query.add_columns(db.func.count(Solves.chalid).label('solves')).group_by(Solves.chalid).order_by('solves DESC').first() - least_solved_chal = Solves.query.add_columns(db.func.count(Solves.chalid).label('solves')).group_by(Solves.chalid).order_by('solves ASC').first() + least_solved_chal = Challenges.query.add_columns(db.func.count(Solves.chalid).label('solves')).outerjoin(Solves).group_by(Challenges.id).order_by('solves ASC').first() db.session.close() diff --git a/templates/admin/statistics.html b/templates/admin/statistics.html index 45580cf6..64a87c35 100644 --- a/templates/admin/statistics.html +++ b/templates/admin/statistics.html @@ -13,7 +13,7 @@

Most solved: {{ most_solved[0].chal.name }} with {{ most_solved[1] }} solves

{% endif %} {% if least_solved %} -

Least solved: {{ least_solved[0].chal.name }} with {{ least_solved[1] }} solves

+

Least solved: {{ least_solved[0].name }} with {{ least_solved[1] }} solves

{% endif %}