Skip to content

Commit

Permalink
#9453 Change the review API to fetch additional data for round history
Browse files Browse the repository at this point in the history
  • Loading branch information
nibou230 authored and defstat committed May 1, 2024
1 parent 111c724 commit 543ff04
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
52 changes: 45 additions & 7 deletions api/v1/reviews/PKPReviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Route;
use PKP\core\PKPApplication;
use PKP\core\PKPBaseController;
use PKP\core\PKPRequest;
use PKP\db\DAORegistry;
Expand All @@ -30,6 +31,7 @@
use PKP\security\authorization\SubmissionAccessPolicy;
use PKP\security\authorization\UserRolesRequiredPolicy;
use PKP\security\Role;
use PKP\submissionFile\SubmissionFile;

class PKPReviewController extends PKPBaseController
{
Expand Down Expand Up @@ -96,9 +98,7 @@ public function getHistory(Request $illuminateRequest): JsonResponse
$context = $request->getContext();
$contextId = $context->getId();

// TODO: get the reviewer ID from the request or from the route?
$reviewerId = $request->getUser()->getId();
//$reviewerId = $illuminateRequest->route('reviewerId');
$submissionId = $illuminateRequest->route('submissionId');
$reviewRoundId = $illuminateRequest->route('reviewRoundId');

Expand All @@ -117,7 +117,13 @@ public function getHistory(Request $illuminateRequest): JsonResponse
}

$submission = Repo::submission()->get($submissionId, $contextId);
$publicationTitle = $submission->getCurrentPublication()->getLocalizedTitle();
$publication = $submission->getCurrentPublication();
$publicationTitle = $publication->getLocalizedTitle();

$section = Repo::section()->get($submission->getSectionId());
$publicationType = $section->getLocalizedData('title');
$publicationAbstract = $publication->getLocalizedData('abstract');
$publicationKeywords = implode(', ', $publication->getLocalizedData('keywords'));

$declineEmail = null;
if ($reviewAssignment->getDeclined()) {
Expand Down Expand Up @@ -154,25 +160,57 @@ public function getHistory(Request $illuminateRequest): JsonResponse
}
}

$genreDao = DAORegistry::getDAO('GenreDAO');
$fileGenres = $genreDao->getByContextId($contextId)->toArray();

$attachments = Repo::submissionFile()->getCollector()
->filterBySubmissionIds([$submissionId])
->filterByReviewRoundIds([$reviewRoundId])
->filterByUploaderUserIds([$reviewerId])
->filterByFileStages([SubmissionFile::SUBMISSION_FILE_REVIEW_ATTACHMENT])
->filterByAssoc(PKPApplication::ASSOC_TYPE_REVIEW_ASSIGNMENT, [$reviewAssignmentId])
->getMany();
$attachmentsProps = Repo::submissionFile()
->getSchemaMap()
->mapMany($attachments, $fileGenres)
->toArray();

$lastReviewAssignment = Repo::reviewAssignment()->getCollector()
->filterByContextIds([$contextId])
->filterBySubmissionIds([$submissionId])
->filterByReviewerIds([$reviewerId])
->filterByLastReviewRound(true)
->getMany()
->first();
$displayFiles = $lastReviewAssignment->getDeclined() != 1;

$reviewRoundHistoryProps = [
$filesProps = [];
if ($lastReviewAssignment->getDeclined() != 1) {
$files = Repo::submissionFile()->getCollector()
->filterBySubmissionIds([$submissionId])
->filterByReviewRoundIds([$reviewRoundId])
->filterByAssoc(PKPApplication::ASSOC_TYPE_REVIEW_ROUND, [$reviewAssignmentId])
->filterByFileStages([SubmissionFile::SUBMISSION_FILE_REVIEW_FILE])
->getMany();
$filesProps = Repo::submissionFile()
->getSchemaMap()
->mapMany($files, $fileGenres)
->toArray();
}

$reviewRoundHistory = [
'publicationTitle' => $publicationTitle,
'publicationType' => $publicationType,
'publicationAbstract' => $publicationAbstract,
'publicationKeywords' => $publicationKeywords,
'declineEmail' => $declineEmail,
'reviewAssignment' => $reviewAssignmentProps,
'recommendation' => $recommendation,
'comments' => $viewableComments,
'privateComments' => $privateComments,
'displayFiles' => $displayFiles,
'attachments' => array_values($attachmentsProps),
'files' => array_values($filesProps),
];

return response()->json($reviewRoundHistoryProps, Response::HTTP_OK);
return response()->json($reviewRoundHistory, Response::HTTP_OK);
}
}
3 changes: 2 additions & 1 deletion pages/reviewer/PKPReviewerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public function submission(array $args, PKPRequest $request): void
$reviewRoundHistories[] = [
'submissionId' => $submissionId,
'reviewRoundId' => $reviewRoundId,
'reviewRoundNumber' => $reviewAssignment->getRound()
'reviewRoundNumber' => $reviewAssignment->getRound(),
'submittedOn' => $reviewAssignment->getDateCompleted()
];
}
}
Expand Down

0 comments on commit 543ff04

Please sign in to comment.