Skip to content

Commit 6f69c8b

Browse files
committed
fix: add existence check for ProblemParagraphMapping association
1 parent 98b58e7 commit 6f69c8b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

apps/dataset/serializers/paragraph_serializers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ def is_valid(self, *, raise_exception=True):
226226
def association(self, with_valid=True, with_embedding=True):
227227
if with_valid:
228228
self.is_valid(raise_exception=True)
229+
# 已关联则直接返回
230+
if QuerySet(ProblemParagraphMapping).filter(
231+
dataset_id=self.data.get('dataset_id'),
232+
document_id=self.data.get('document_id'),
233+
paragraph_id=self.data.get('paragraph_id'),
234+
problem_id=self.data.get('problem_id')
235+
).exists():
236+
return True
229237
problem = QuerySet(Problem).filter(id=self.data.get("problem_id")).first()
230238
problem_paragraph_mapping = ProblemParagraphMapping(id=uuid.uuid1(),
231239
document_id=self.data.get('document_id'),

0 commit comments

Comments
 (0)