hotfix/server: fix duplication of topics

This commit is contained in:
2023-11-02 19:40:45 +01:00
parent 37f6fe6345
commit 9642d0fd1e
3 changed files with 15 additions and 6 deletions

View File

@@ -106,9 +106,9 @@ class Transcript(BaseModel):
return ev
def upsert_topic(self, topic: TranscriptTopic):
existing_topic = next((t for t in self.topics if t.id == topic.id), None)
if existing_topic:
existing_topic.update_from(topic)
index = next((i for i, t in enumerate(self.topics) if t.id == topic.id), None)
if index is not None:
self.topics[index] = topic
else:
self.topics.append(topic)