quick fix participant get create

This commit is contained in:
Sara
2023-12-08 19:44:47 +01:00
parent eef030e54c
commit c12f396b82
4 changed files with 48 additions and 13 deletions

View File

@@ -152,14 +152,17 @@ class Transcript(BaseModel):
self.topics.append(topic) self.topics.append(topic)
def upsert_participant(self, participant: TranscriptParticipant): def upsert_participant(self, participant: TranscriptParticipant):
index = next( if self.participants:
(i for i, p in enumerate(self.participants) if p.id == participant.id), index = next(
None, (i for i, p in enumerate(self.participants) if p.id == participant.id),
) None,
if index is not None: )
self.participants[index] = participant if index is not None:
self.participants[index] = participant
else:
self.participants.append(participant)
else: else:
self.participants.append(participant) self.participants = [participant]
return participant return participant
def delete_participant(self, participant_id: str): def delete_participant(self, participant_id: str):

View File

@@ -59,12 +59,13 @@ async def transcript_add_participant(
) )
# ensure the speaker is unique # ensure the speaker is unique
for p in transcript.participants: if transcript.participants:
if p.speaker == participant.speaker: for p in transcript.participants:
raise HTTPException( if p.speaker == participant.speaker:
status_code=400, raise HTTPException(
detail="Speaker already assigned", status_code=400,
) detail="Speaker already assigned",
)
obj = await transcripts_controller.upsert_participant( obj = await transcripts_controller.upsert_participant(
transcript, TranscriptParticipant(**participant.dict()) transcript, TranscriptParticipant(**participant.dict())

File diff suppressed because one or more lines are too long

24
server/transcript.sql Normal file

File diff suppressed because one or more lines are too long