fixed bug in participant API GET with user_id parameter

This commit is contained in:
Daniel Schick 2024-12-11 09:39:26 +01:00
parent ebb2182c4c
commit 50cecc6a9d

View File

@ -19,8 +19,13 @@ def GetParticipant(options):
# query = SQLQuery.get_participant_by_user_id()
query = ("SELECT p.id as id, p.name as name, p.street as street, p.postal_code as postal_code, p.city as city, p.type as type, p.flags as flags, " +
"p.created as created, p.modified as modified, p.deleted as deleted FROM participant p " +
"INNER JOIN user u WHERE u.participant_id = p.id and u.id = %d") % options["user_id"]
"INNER JOIN user u WHERE u.participant_id = p.id and u.id = %s") % options["user_id"]
data = commands.query(query, model=model.Participant)
for participant in data:
port_query = "SELECT port_id FROM participant_port_map WHERE participant_id=?id?"
for record in commands.query(port_query, model=model.Port_Assignment, param={"id" : participant.id}, buffered=False):
pa = model.Port_Assignment(record.port_id)
participant.ports.append(pa.port_id)
else:
# query = SQLQuery.get_participants()
if "participant_id" in options:
@ -29,7 +34,7 @@ def GetParticipant(options):
"FROM participant p " +
"JOIN participant_port_map ON p.id = participant_port_map.participant_id " +
"WHERE participant_port_map.port_id IN " +
"(SELECT port_id FROM participant_port_map where participant_id = %d) " +
"(SELECT port_id FROM participant_port_map where participant_id = %s) " +
"GROUP BY id " +
"ORDER BY p.name") % options["participant_id"]
else:
@ -41,7 +46,7 @@ def GetParticipant(options):
data = commands.query(query, model=model.Participant)
for participant in data:
port_query = "SELECT port_id FROM participant_port_map WHERE participant_id=?id?";
port_query = "SELECT port_id FROM participant_port_map WHERE participant_id=?id?"
for record in commands.query(port_query, model=model.Port_Assignment, param={"id" : participant.id}, buffered=False):
pa = model.Port_Assignment(record.port_id)
participant.ports.append(pa.port_id)