Skip to content

Commit 1ce7bb3

Browse files
committed
#11252 Fix review assignment collector
1 parent 51fb604 commit 1ce7bb3

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

classes/security/authorization/internal/ReviewAssignmentAccessPolicy.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ public function effect(): int
6969

7070
$reviewAssignment = Repo::reviewAssignment()->getCollector()
7171
->filterBySubmissionIds([$submission->getId()])
72-
->filterByReviewerIds([$user->getId()])
73-
->filterByLastReviewRound(true)
72+
->filterByReviewerIds([$user->getId()], true)
7473
->getMany()
7574
->first();
7675

classes/submission/reviewAssignment/Collector.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,12 @@ public function getQueryBuilder(): Builder
285285
// Aggregate the latest review round number for the given assignment
286286
->leftJoinSub(
287287
DB::table('review_rounds', 'rr')
288-
->select('rr.submission_id')
288+
->select(['rr.submission_id', 'rr.stage_id'])
289289
->selectRaw('MAX(rr.round) as current_round')
290-
->selectRaw('MAX(rr.stage_id) as current_stage')
291-
->groupBy('rr.submission_id'),
290+
->groupBy(['rr.submission_id', 'rr.stage_id'])
291+
// OMP has 2 review stages, must pick the latest on to determine the current review round correctly
292+
->havingRaw('stage_id = MAX(rr.stage_id)')
293+
->distinct(),
292294
'agrr',
293295
fn (JoinClause $join) => $join->on('ra.submission_id', '=', 'agrr.submission_id')
294296
)
@@ -315,7 +317,7 @@ public function getQueryBuilder(): Builder
315317
$q->when($this->isLastReviewRound || $this->isIncomplete, function (Builder $q) {
316318
$q
317319
->whereColumn('ra.round', '=', 'agrr.current_round') // assignments from the last review round only
318-
->whereColumn('ra.stage_id', '=', 'agrr.current_stage') // assignments for the current review stage only (for OMP)
320+
->whereColumn('ra.stage_id', '=', 'agrr.stage_id') // assignments for the current review stage only (for OMP)
319321
->when(
320322
$this->isIncomplete,
321323
fn (Builder $q) => $q
@@ -454,14 +456,13 @@ public function getQueryBuilder(): Builder
454456
->leftJoinSub(
455457
DB::table('review_assignments as ramax')
456458
->select(['ramax.submission_id', 'ramax.reviewer_id'])
457-
->selectRaw('MAX(ramax.round) as latest_round')
458459
->selectRaw('MAX(ramax.stage_id) as latest_stage')
459460
->whereIn('ramax.reviewer_id', $this->reviewerIds)
460461
->groupBy(['ramax.submission_id', 'ramax.reviewer_id']),
461462
'agrmax',
462463
fn (JoinClause $join) => $join->on('ra.submission_id', '=', 'agrmax.submission_id')
463464
)
464-
->whereColumn('ra.round', 'agrmax.latest_round') // assignments from the last review round per reviewer only
465+
->whereColumn('ra.round', 'agrr.current_round') // assignments from the last review round per reviewer only
465466
->whereColumn('ra.stage_id', 'agrmax.latest_stage') // assignments for the current review stage only (for OMP)
466467
)
467468
);

0 commit comments

Comments
 (0)