Skip to content

pkp/pkp-lib#11252 Fix review assignment collector #11314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: stable-3_5_0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public function effect(): int

$reviewAssignment = Repo::reviewAssignment()->getCollector()
->filterBySubmissionIds([$submission->getId()])
->filterByReviewerIds([$user->getId()])
->filterByLastReviewRound(true)
->filterByReviewerIds([$user->getId()], true)
->getMany()
->first();

Expand Down
13 changes: 7 additions & 6 deletions classes/submission/reviewAssignment/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,12 @@ public function getQueryBuilder(): Builder
// Aggregate the latest review round number for the given assignment
->leftJoinSub(
DB::table('review_rounds', 'rr')
->select('rr.submission_id')
->select(['rr.submission_id', 'rr.stage_id'])
->selectRaw('MAX(rr.round) as current_round')
->selectRaw('MAX(rr.stage_id) as current_stage')
->groupBy('rr.submission_id'),
->groupBy(['rr.submission_id', 'rr.stage_id'])
// OMP has 2 review stages, must pick the latest on to determine the current review round correctly
->havingRaw('stage_id = MAX(rr.stage_id)')
->distinct(),
'agrr',
fn (JoinClause $join) => $join->on('ra.submission_id', '=', 'agrr.submission_id')
)
Expand All @@ -315,7 +317,7 @@ public function getQueryBuilder(): Builder
$q->when($this->isLastReviewRound || $this->isIncomplete, function (Builder $q) {
$q
->whereColumn('ra.round', '=', 'agrr.current_round') // assignments from the last review round only
->whereColumn('ra.stage_id', '=', 'agrr.current_stage') // assignments for the current review stage only (for OMP)
->whereColumn('ra.stage_id', '=', 'agrr.stage_id') // assignments for the current review stage only (for OMP)
->when(
$this->isIncomplete,
fn (Builder $q) => $q
Expand Down Expand Up @@ -454,14 +456,13 @@ public function getQueryBuilder(): Builder
->leftJoinSub(
DB::table('review_assignments as ramax')
->select(['ramax.submission_id', 'ramax.reviewer_id'])
->selectRaw('MAX(ramax.round) as latest_round')
->selectRaw('MAX(ramax.stage_id) as latest_stage')
->whereIn('ramax.reviewer_id', $this->reviewerIds)
->groupBy(['ramax.submission_id', 'ramax.reviewer_id']),
'agrmax',
fn (JoinClause $join) => $join->on('ra.submission_id', '=', 'agrmax.submission_id')
)
->whereColumn('ra.round', 'agrmax.latest_round') // assignments from the last review round per reviewer only
->whereColumn('ra.round', 'agrr.current_round') // assignments from the last review round per reviewer only
->whereColumn('ra.stage_id', 'agrmax.latest_stage') // assignments for the current review stage only (for OMP)
)
);
Expand Down