From e1563ab64aa56c725d91200c3975eab6442071c3 Mon Sep 17 00:00:00 2001 From: Niclas Dobbertin Date: Thu, 9 Jul 2026 23:39:40 +0200 Subject: remove starting comma to prevent empty participant but counting --- add_participant.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'add_participant.py') diff --git a/add_participant.py b/add_participant.py index 948b4c6..7431b3b 100644 --- a/add_participant.py +++ b/add_participant.py @@ -13,19 +13,24 @@ con = sqlite3.connect(db_path) cur = con.cursor() - def add_participant(meeting_id, part_name, data): select = cur.execute( "SELECT participants FROM meeting WHERE meeting_id = ?;", (meeting_id,) ) participants = select.fetchone()[0] - print(participants) - if part_name in participants.split(","): + if participants is not None and part_name in participants.split(","): print("Participant name already taken!") else: cur.execute( "UPDATE meeting SET participants = ? WHERE meeting_id = ?;", - (participants + "," + part_name, meeting_id), + ( + ( + participants + "," + part_name + if participants is not None + else part_name + ), + meeting_id, + ), ) for datum in data: if datum[1]: @@ -34,7 +39,9 @@ def add_participant(meeting_id, part_name, data): (datum[0],), ) result = select.fetchone() - new_confirming = result[0] + "," + part_name + new_confirming = ( + result[0] + "," + part_name if result[0] is not None else part_name + ) cur.execute( f"UPDATE meeting_dates_{meeting_id} SET confirming = ? WHERE date = ?;", ( @@ -48,7 +55,9 @@ def add_participant(meeting_id, part_name, data): (datum[0],), ) result = select.fetchone() - new_declining = result[0] + "," + part_name + new_declining = ( + result[0] + "," + part_name if result[0] is not None else part_name + ) cur.execute( f"UPDATE meeting_dates_{meeting_id} SET declining = ? WHERE date = ?;", ( -- cgit v1.2.3