File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
backend/code_review_backend/issues Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -274,9 +274,20 @@ def create(self, validated_data):
274
274
ignore_conflicts = True ,
275
275
)
276
276
# List issues again to ensure ID are synced for creating links
277
- issues_with_links = (
277
+ issues_with_links = list (
278
278
Issue .objects .values ("issue_links" )
279
- .filter (hash__in = [issue .hash for issue in issues ])
279
+ .filter (
280
+ Q (
281
+ # Issue is new for this diff/revision
282
+ issue_links__isnull = True ,
283
+ )
284
+ | Q (
285
+ # Issue exists for this diff/revision
286
+ issue_links__diff = diff ,
287
+ issue_links__revision = self .context ["revision" ],
288
+ ),
289
+ hash__in = [issue .hash for issue in issues ],
290
+ )
280
291
# Needed for re-serialization
281
292
.annotate (publishable = Q (issue_links__in_patch = True ) & Q (level = LEVEL_ERROR ))
282
293
.values (
@@ -294,6 +305,7 @@ def create(self, validated_data):
294
305
"issue_links__nb_lines" ,
295
306
"issue_links__char" ,
296
307
)
308
+ .iterator ()
297
309
)
298
310
# Group existing links by issue
299
311
grouped_issues = [
Original file line number Diff line number Diff line change @@ -419,7 +419,6 @@ def test_create_issue_bulk_alread_exists(self):
419
419
)
420
420
421
421
# Calling again with the same payload should give the same result
422
- # 1 less request is fired to the DB because no IssueLink is created
423
422
with self .assertNumQueries (5 ):
424
423
response = self .client .post (
425
424
f"/v1/revision/{ self .revision .id } /issues/" , payload_2 , format = "json"
You can’t perform that action at this time.
0 commit comments