fix: add check for existing problem-paragraph mapping before processing
--bug=1060558 --user=刘瑞斌 【github#3868】知识库分段,重复添加同一个问题,问题会重复多次关联分段 https://www.tapd.cn/62980211/s/1756889
This commit is contained in:
parent
044465fcc6
commit
4847eba4bf
@ -406,6 +406,15 @@ class ParagraphSerializers(serializers.Serializer):
|
|||||||
def association(self, with_valid=True, with_embedding=True):
|
def association(self, with_valid=True, with_embedding=True):
|
||||||
if with_valid:
|
if with_valid:
|
||||||
self.is_valid(raise_exception=True)
|
self.is_valid(raise_exception=True)
|
||||||
|
# 已关联则直接返回
|
||||||
|
if QuerySet(ProblemParagraphMapping).filter(
|
||||||
|
knowledge_id=self.data.get('knowledge_id'),
|
||||||
|
document_id=self.data.get('document_id'),
|
||||||
|
paragraph_id=self.data.get('paragraph_id'),
|
||||||
|
problem_id=self.data.get('problem_id')
|
||||||
|
).exists():
|
||||||
|
return True
|
||||||
|
|
||||||
problem = QuerySet(Problem).filter(id=self.data.get("problem_id")).first()
|
problem = QuerySet(Problem).filter(id=self.data.get("problem_id")).first()
|
||||||
problem_paragraph_mapping = ProblemParagraphMapping(id=uuid.uuid7(),
|
problem_paragraph_mapping = ProblemParagraphMapping(id=uuid.uuid7(),
|
||||||
document_id=self.data.get('document_id'),
|
document_id=self.data.get('document_id'),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user