Skip to content
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

pkp/pkp-lib#10853 Fix review round data retrieval in submission schema #1820

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions classes/submission/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ protected function mapByProperties(array $props, Submission $submission, bool|Co
$locales[] = $submissionLocale;
}

$reviewRounds = $this->getGroupedReviewRoundsFromSubmission($submission);
$currentReviewRound = $reviewRounds->flatten()->sort()->last(); /** @var ReviewRound|null $currentReviewRound */
$reviewRounds = $this->getReviewRoundsFromSubmission($submission);
$currentReviewRound = $reviewRounds->last(); /** @var ReviewRound|null $currentReviewRound */

foreach ($props as $prop) {
switch ($prop) {
Expand All @@ -86,7 +86,7 @@ protected function mapByProperties(array $props, Submission $submission, bool|Co
$output[$prop] = $currentReviewRound && $this->reviewAssignments->count() >= intval($this->context->getData('numReviewersPerSubmission'));
break;
case 'reviewRounds':
$output[$prop] = $this->getPropertyReviewRounds($reviewRounds->flatten());
$output[$prop] = $this->getPropertyReviewRounds($reviewRounds);
break;
case 'revisionsRequested':
$output[$prop] = $currentReviewRound && $currentReviewRound->getData('status') == ReviewRound::REVIEW_ROUND_STATUS_REVISIONS_REQUESTED;
Expand Down Expand Up @@ -124,13 +124,13 @@ protected function mapByProperties(array $props, Submission $submission, bool|Co
}

/**
* @return Collection<Collection<ReviewRound>> grouped list of review rounds related to particular submission
* @return Collection<ReviewRound> list of review rounds related to particular submission. Sorted by stage and round number.
*/
protected function getGroupedReviewRoundsFromSubmission(Submission $submission): Collection
protected function getReviewRoundsFromSubmission(Submission $submission): Collection
{
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /** @var ReviewRoundDAO $reviewRoundDao */
return collect($reviewRoundDao->getBySubmissionId($submission->getId())->toIterator())
->groupBy(fn (ReviewRound $reviewRound) => $reviewRound->getData('round'));
->sortBy(fn ($item) => [$item->getData('stageId'), $item->getData('round')]);
}

/**
Expand Down
Loading