Skip to content

Commit

Permalink
pkp#8885 Stage Assignments model pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy-1 committed Apr 29, 2024
1 parent 27b8e2d commit 9a97657
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions classes/submission/maps/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function mapMany(Enumerable $collection, LazyCollection $userGroups, arra
$associatedReviewAssignments = $this->reviewAssignments->groupBy(fn (ReviewAssignment $reviewAssignment, int $key) =>
$reviewAssignment->getData('submissionId'));
$associatedStageAssignments = $this->stageAssignments->groupBy(fn (StageAssignment $stageAssignment, int $key) =>
$stageAssignment->getData('submissionId'));
$stageAssignment->submissionId);

return $collection->map(
fn ($item) =>
Expand Down Expand Up @@ -204,7 +204,7 @@ public function summarizeMany(Enumerable $collection, LazyCollection $userGroups
);
$associatedStageAssignment = $this->stageAssignments->groupBy(
fn (StageAssignment $stageAssignment, int $key) =>
$stageAssignment->getData('submissionId')
$stageAssignment->submissionId
);

return $collection->map(
Expand Down Expand Up @@ -264,7 +264,7 @@ public function mapManyToSubmissionsList(Enumerable $collection, LazyCollection
);
$associatedStageAssignment = $this->stageAssignments->groupBy(
fn (StageAssignment $stageAssignment, int $key) =>
$stageAssignment->getData('submissionId')
$stageAssignment->submissionId
);

return $collection->map(
Expand Down Expand Up @@ -419,7 +419,6 @@ protected function getPropertyReviewAssignments(Enumerable $reviewAssignments):
$reviews[] = [
'id' => (int) $reviewAssignment->getId(),
'isCurrentUserAssigned' => $currentUser->getId() == (int) $reviewAssignment->getReviewerId(),
'dateAssigned' => $reviewAssignment->getData('dateAssigned'),
'statusId' => (int) $reviewAssignment->getStatus(),
'status' => __($reviewAssignment->getStatusKey()),
'dateDue' => $dateDue,
Expand Down Expand Up @@ -625,7 +624,7 @@ protected function getPropertyStageAssignments(Enumerable $stageAssignments): bo
}

foreach ($stageAssignments as $stageAssignment) {
if (!$stageAssignment->getRecommendOnly()) {
if (!$stageAssignment->recommendOnly) {
return true;
}
}
Expand All @@ -648,14 +647,14 @@ protected function getUserGroup(int $userGroupId): ?UserGroup
*
* @param Enumerable<Submission> $submissions
*
* @return LazyCollection<StageAssignment> The collection of stage assignments associated with submissions
* @return Collection<StageAssignment> The collection of stage assignments associated with submissions
*/
protected function getStageAssignmentsBySubmissions(Enumerable $submissions, array $roleIds = []): LazyCollection
protected function getStageAssignmentsBySubmissions(Enumerable $submissions, array $roleIds = []): Collection
{
$submissionIds = $submissions->map(fn (Submission $submission) => $submission->getId())->toArray();

$stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /** @var StageAssignmentDAO $stageAssignmentDao */
return $stageAssignmentDao->getCurrentBySubmissionIds($submissionIds, $roleIds)->remember();
return StageAssignment::withSubmissionIds($submissionIds)
->withRoleIds($roleIds)
->get();
}

/**
Expand All @@ -678,7 +677,7 @@ protected function getReviewRoundsFromSubmission(Submission $submission): Collec
*/
protected function areRecommendationsIn(ReviewRound $currentReviewRound, Enumerable $stageAssignments): ?bool
{
$hasDecidingEditors = $stageAssignments->first(fn (StageAssignment $stageAssignment) => $stageAssignment->getData('recommendOnly'));
$hasDecidingEditors = $stageAssignments->first(fn (StageAssignment $stageAssignment) => $stageAssignment->recommendOnly);
if (!$hasDecidingEditors) {
return null;
}
Expand Down

0 comments on commit 9a97657

Please sign in to comment.