Skip to content

Commit

Permalink
pkp/pkp-lib#10515 Return all review rounds
Browse files Browse the repository at this point in the history
  • Loading branch information
taslangraham authored Oct 18, 2024
2 parents 7de2e4d + f8ee7ba commit 4c3766e
Showing 1 changed file with 53 additions and 22 deletions.
75 changes: 53 additions & 22 deletions classes/submission/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use APP\submission\Submission;
use Illuminate\Support\Collection;
use PKP\db\DAORegistry;
use PKP\submission\reviewRound\ReviewRound;
use PKP\submission\reviewRound\ReviewRoundDAO;

class Schema extends \PKP\submission\maps\Schema
{
Expand All @@ -37,39 +39,68 @@ protected function getSubmissionsListProps(): array
/** @copydoc \PKP\submission\maps\Schema::mapByProperties() */
protected function mapByProperties(array $props, Submission $submission, bool|Collection $anonymizeReviews = false): array
{
$output = parent::mapByProperties($props, $submission, $anonymizeReviews);

if (in_array('urlPublished', $props)) {
$output['urlPublished'] = $this->request->getDispatcher()->url(
$this->request,
Application::ROUTE_PAGE,
$this->context->getPath(),
'catalog',
'book',
[$submission->getBestId()]
);
}

if (in_array('featured', $props)) {
$featureDao = DAORegistry::getDAO('FeatureDAO'); /** @var FeatureDAO $featureDao */
$output['featured'] = $featureDao->getFeaturedAll($submission->getId());
}

if (in_array('newRelease', $props)) {
$newReleaseDao = DAORegistry::getDAO('NewReleaseDAO'); /** @var NewReleaseDAO $newReleaseDao */
$output['newRelease'] = $newReleaseDao->getNewReleaseAll($submission->getId());
}
$output = parent::mapByProperties(array_diff($props, ['recommendationsIn', 'reviewersNotAssigned', 'reviewRounds', 'revisionsRequested', 'revisionsSubmitted']), $submission, $anonymizeReviews);

$locales = $this->context->getSupportedSubmissionMetaDataLocales();

if (!in_array($submissionLocale = $submission->getData('locale'), $locales)) {
$locales[] = $submissionLocale;
}

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

foreach ($props as $prop) {
switch ($prop) {
case 'recommendationsIn':
$output[$prop] = $currentReviewRound ? $this->areRecommendationsIn($currentReviewRound, $this->stageAssignments) : null;
break;
case 'reviewersNotAssigned':
$output[$prop] = $currentReviewRound && $this->reviewAssignments->count() >= intval($this->context->getData('numReviewersPerSubmission'));
break;
case 'reviewRounds':
$output[$prop] = $this->getPropertyReviewRounds($reviewRounds->flatten());
break;
case 'revisionsRequested':
$output[$prop] = $currentReviewRound && $currentReviewRound->getData('status') == ReviewRound::REVIEW_ROUND_STATUS_REVISIONS_REQUESTED;
break;
case 'revisionsSubmitted':
$output[$prop] = $currentReviewRound && $currentReviewRound->getData('status') == ReviewRound::REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED;
break;
case 'featured':
$featureDao = DAORegistry::getDAO('FeatureDAO'); /** @var FeatureDAO $featureDao */
$output['featured'] = $featureDao->getFeaturedAll($submission->getId());
break;
case 'newRelease':
$newReleaseDao = DAORegistry::getDAO('NewReleaseDAO'); /** @var NewReleaseDAO $newReleaseDao */
$output['newRelease'] = $newReleaseDao->getNewReleaseAll($submission->getId());
break;
case 'urlPublished':
$output['urlPublished'] = $this->request->getDispatcher()->url(
$this->request,
Application::ROUTE_PAGE,
$this->context->getPath(),
'catalog',
'book',
[$submission->getBestId()]
);
break;
}
}


$output = $this->schemaService->addMissingMultilingualValues($this->schemaService::SCHEMA_SUBMISSION, $output, $locales);

ksort($output);

return $this->withExtensions($output, $submission);
}

/** @copydoc \PKP\submission\maps\Schema::getReviewRoundsFromSubmission*/
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'));
}
}

0 comments on commit 4c3766e

Please sign in to comment.