Skip to content

Commit

Permalink
#9453 Matching the correct decline email and get review comments data
Browse files Browse the repository at this point in the history
  • Loading branch information
nibou230 authored and defstat committed May 1, 2024
1 parent 363bc92 commit 111c724
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions api/v1/reviews/PKPReviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,20 @@ public function getHistory(Request $illuminateRequest): JsonResponse
$publicationTitle = $submission->getCurrentPublication()->getLocalizedTitle();

$declineEmail = null;
if (!$reviewAssignment->getDeclined()) {
if ($reviewAssignment->getDeclined()) {
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
$emailLogs = $submissionEmailLogDao->getBySenderId($submissionId, SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_DECLINE, $reviewerId)->toArray();
// TODO: look for the right email log with the right round number.
if ($emailLogs) {
$emailLog = $emailLogs[0];
$declineEmail = [
'subject' => $emailLog->getData('subject'),
'body' => $emailLog->getData('body'),
];
foreach ($emailLogs as $emailLog) {
$dateSent = substr($emailLog->getData('dateSent'), 0, 10);
$dateConfirmed = substr($reviewAssignment->getData('dateConfirmed'), 0, 10);
// Compare the dates to get the decline email associated to the current round.
if ($dateSent === $dateConfirmed) {
$declineEmail = [
'subject' => $emailLog->getData('subject'),
'body' => $emailLog->getData('body'),
];
break;
}
}
}

Expand All @@ -138,10 +142,17 @@ public function getHistory(Request $illuminateRequest): JsonResponse

$reviewAssignmentId = $reviewAssignment->getId();
$submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO');
$comments = $submissionCommentDao->getReviewerCommentsByReviewerId($submissionId, $reviewerId, $reviewAssignmentId, true)->toArray();
$privateComments = $submissionCommentDao->getReviewerCommentsByReviewerId($submissionId, $reviewerId, $reviewAssignmentId, false)->toArray();

// TODO: get the comments data...
$allSubmissionComments = $submissionCommentDao->getReviewerCommentsByReviewerId($submissionId, $reviewerId, $reviewAssignmentId)->toArray();
$viewableComments = [];
$privateComments = [];
foreach ($allSubmissionComments as $submissionComment) {
$comments = $submissionComment->getData('comments');
if ($submissionComment->getData('viewable')) {
$viewableComments[] = $comments;
} else {
$privateComments[] = $comments;
}
}

$lastReviewAssignment = Repo::reviewAssignment()->getCollector()
->filterByContextIds([$contextId])
Expand All @@ -157,7 +168,7 @@ public function getHistory(Request $illuminateRequest): JsonResponse
'declineEmail' => $declineEmail,
'reviewAssignment' => $reviewAssignmentProps,
'recommendation' => $recommendation,
'comments' => $comments,
'comments' => $viewableComments,
'privateComments' => $privateComments,
'displayFiles' => $displayFiles,
];
Expand Down

0 comments on commit 111c724

Please sign in to comment.