From 0f6c7694b9502e8c66c2d5fae046c0b9a6b6ac01 Mon Sep 17 00:00:00 2001 From: Aday Bujeda Date: Wed, 15 May 2024 23:31:40 +0100 Subject: [PATCH] Added review files check to submission closed scheduled task --- ...SubmissionClosedAuthorNotification.inc.php | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/pprOjsPlugin/tasks/PPRSubmissionClosedAuthorNotification.inc.php b/pprOjsPlugin/tasks/PPRSubmissionClosedAuthorNotification.inc.php index 86a0c16..6092a8f 100644 --- a/pprOjsPlugin/tasks/PPRSubmissionClosedAuthorNotification.inc.php +++ b/pprOjsPlugin/tasks/PPRSubmissionClosedAuthorNotification.inc.php @@ -73,6 +73,7 @@ function executeForContext($context, $pprPluginSettings) { 'closedSubmissionsAfterPeriod' => 0, 'closedSubmissionsWithNotifications' => 0, 'sendToAuthorMissing' => 0, + 'reviewFilesMissing' => 0, 'sentNotifications' => 0, ]; @@ -107,6 +108,14 @@ function executeForContext($context, $pprPluginSettings) { continue; } + if (!$this->reviewFilesForSubmission($closedSubmission)) { + // ALL CLOSED SUBMISSIONS SHOULD HAVE REVIEW FILES + // LOG TO DEBUG WITH PRODUCT TEAM + $this->log($context, sprintf("reviewFiles not found - closedSubmission=%s", $closedSubmission->getId())); + $metrics['reviewFilesMissing']++; + continue; + } + $authorNotifications = $pprNotificationRegistry->getSubmissionClosedAuthorNotification($closedSubmission->getId()); if (empty($authorNotifications)) { $this->sendNotification($closedSubmission, $context); @@ -118,7 +127,29 @@ function executeForContext($context, $pprPluginSettings) { } } - $this->log($context, sprintf("Completed - closedSubmissions=%s closedSubmissionsAfterPeriod=%s sendToAuthorMissing=%s closedSubmissionsWithNotifications=%s sentNotifications=%s", $metrics['closedSubmissions'], $metrics['closedSubmissionsAfterPeriod'], $metrics['sendToAuthorMissing'], $metrics['closedSubmissionsWithNotifications'], $metrics['sentNotifications'])); + $this->log($context, sprintf("Completed - closedSubmissions=%s closedSubmissionsAfterPeriod=%s sendToAuthorMissing=%s reviewFilesMissing=%s closedSubmissionsWithNotifications=%s sentNotifications=%s", + $metrics['closedSubmissions'], + $metrics['closedSubmissionsAfterPeriod'], + $metrics['sendToAuthorMissing'], + $metrics['reviewFilesMissing'], + $metrics['closedSubmissionsWithNotifications'], + $metrics['sentNotifications'])); + } + + private function reviewFilesForSubmission($submission) { + import('lib.pkp.classes.submission.SubmissionFile'); // Bring the file constants. + $params = [ + 'submissionIds' => [$submission->getId()], + 'fileStages' => [SUBMISSION_FILE_REVIEW_ATTACHMENT], + ]; + $submissionFilesIterator = Services::get('submissionFile')->getMany($params); + $submissionReviewFiles = iterator_to_array($submissionFilesIterator); + + if (empty($submissionReviewFiles)) { + return false; + } + + return true; } private function requestedRevisionsForSubmission($submission) {