From b72b373d8d8bd111eed5a25e8e4a64590281f9e9 Mon Sep 17 00:00:00 2001 From: Matte23 Date: Fri, 7 Nov 2025 17:14:18 +0100 Subject: [PATCH] fix: Change all() with first() --- __init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index fab664d..4d974da 100644 --- a/__init__.py +++ b/__init__.py @@ -19,9 +19,9 @@ bp = Blueprint(directory_name, __name__, template_folder="templates") def create_flag_if_missing(challenge_id: int, user_id: int, flag_content: str): user_id_str = str(user_id) - flags = Flags.query.filter_by(id=challenge_id, data=user_id_str).all() + flag = Flags.query.filter_by(id=challenge_id, data=user_id_str).first() - if len(flags) == 0: + if flag is None: new_flag = Flags( challenge_id=challenge_id, type="personal", @@ -32,7 +32,7 @@ def create_flag_if_missing(challenge_id: int, user_id: int, flag_content: str): db.session.commit() return new_flag.id - return flags[0].id + return flag @bp.route("/admin/cheaters", methods=["GET"])