Skip to content

Commit 6f4e111

Browse files
Merge branch 'fixFinalDecision330-761' into 'stable-3_3_0'
Corrige problema com decisão final quando há múltiplas decisões See merge request softwares-pkp/plugins_ojs/relatorioscielo!31
2 parents 900c141 + 50da005 commit 6f4e111

4 files changed

Lines changed: 21 additions & 19 deletions

File tree

classes/ScieloPreprintsDAO.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function getFinalDecisionWithDate($submissionId, $locale)
179179
$result = Capsule::table('edit_decisions')
180180
->where('submission_id', $submissionId)
181181
->whereIn('decision', $possibleFinalDecisions)
182-
->orderBy('date_decided', 'asc')
182+
->orderBy('date_decided', 'desc')
183183
->first();
184184

185185
if (is_null($result)) {

classes/ScieloSubmissionsDAO.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function getFinalDecisionWithDate($submissionId, $locale)
136136
$result = Capsule::table('edit_decisions')
137137
->where('submission_id', $submissionId)
138138
->whereIn('decision', $possibleFinalDecisions)
139-
->orderBy('date_decided', 'asc')
139+
->orderBy('date_decided', 'desc')
140140
->first();
141141

142142
if (is_null($result)) {

tests/ScieloSubmissionsReportFactoryTest.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private function createTestSections(): array
5151
return [$firstSectionId, $secondSectionId];
5252
}
5353

54-
private function createSubmission($dateSubmitted = null, $dateFinalDecision = null): int
54+
private function createSubmission($dateSubmitted = null, $finalDecisions = []): int
5555
{
5656
$submissionDao = DAORegistry::getDAO('SubmissionDAO');
5757

@@ -65,27 +65,29 @@ private function createSubmission($dateSubmitted = null, $dateFinalDecision = nu
6565
}
6666
$submissionId = $submissionDao->insertObject($submission);
6767

68-
if (!is_null($dateFinalDecision)) {
69-
$this->addFinalDecision($submissionId, $dateFinalDecision);
68+
if (!empty($finalDecisions)) {
69+
foreach ($finalDecisions as $decisionDate => $decisionType) {
70+
$this->addFinalDecision($submissionId, $decisionDate, $decisionType);
71+
}
7072
}
7173

7274
return $submissionId;
7375
}
7476

7577
private function createTestSubmissions(): array
7678
{
77-
$firstSubmissionId = $this->createSubmission('1921-05-21 11:56:37', '1921-05-24 13:00:00');
78-
$secondSubmissionId = $this->createSubmission('1921-05-29 12:58:29', '1921-06-01 23:41:09');
79-
$thirdSubmissionId = $this->createSubmission('1921-06-14 04:30:08', '1921-06-17 12:00:00');
80-
$fourthSubmissionId = $this->createSubmission('1921-07-08 18:37:12', '1921-07-10 15:49:00');
79+
$firstSubmissionId = $this->createSubmission('1921-05-21 11:56:37', ['1921-05-24 13:00:00' => SUBMISSION_EDITOR_DECISION_DECLINE]);
80+
$secondSubmissionId = $this->createSubmission('1921-05-29 12:58:29', ['1921-06-01 23:41:09' => SUBMISSION_EDITOR_DECISION_DECLINE]);
81+
$thirdSubmissionId = $this->createSubmission('1921-06-14 04:30:08', ['1921-06-17 12:00:00' => SUBMISSION_EDITOR_DECISION_DECLINE]);
82+
$fourthSubmissionId = $this->createSubmission('1921-07-08 18:37:12', ['1921-07-10 15:49:00' => SUBMISSION_EDITOR_DECISION_DECLINE, '1921-11-07 16:00:00' => SUBMISSION_EDITOR_DECISION_ACCEPT]);
8183

8284
return [$firstSubmissionId, $secondSubmissionId, $thirdSubmissionId, $fourthSubmissionId];
8385
}
8486

85-
private function addFinalDecision($submissionId, $dateDecided)
87+
private function addFinalDecision($submissionId, $decisionDate, $decisionType)
8688
{
8789
$editDecisionDao = DAORegistry::getDAO('EditDecisionDAO');
88-
$editDecisionDao->updateEditorDecision($submissionId, ['editDecisionId' => null, 'decision' => SUBMISSION_EDITOR_DECISION_DECLINE, 'dateDecided' => $dateDecided, 'editorId' => 1]);
90+
$editDecisionDao->updateEditorDecision($submissionId, ['editDecisionId' => null, 'decision' => $decisionType, 'dateDecided' => $decisionDate, 'editorId' => 1]);
8991
}
9092

9193
private function createPublication($submissionId, $sectionId, $datePublished = null)
@@ -228,14 +230,14 @@ public function testReportFilterByFinalDecisionDate(): void
228230
$this->reportFactory = new ScieloSubmissionsReportFactory($this->application, $this->contextId, $this->sectionsIds, $this->submissionDateInterval, $this->finalDecisionDateInterval, $this->locale, $this->includeViews);
229231
$report = $this->reportFactory->createReport();
230232

231-
$expectedSubmissions = [$this->submissionsIds[2], $this->submissionsIds[3]];
233+
$expectedSubmissions = [$this->submissionsIds[2]];
232234
$scieloSubmissionsIds = $this->mapScieloSubmissionsToIds($report->getSubmissions());
233235
$this->assertEquals($expectedSubmissions, $scieloSubmissionsIds);
234236
}
235237

236238
public function testReportFilterByFinalDecisionDateSubmissionAtIntervalStart(): void
237239
{
238-
$this->finalDecisionDateInterval = new ClosedDateInterval('1921-07-10', '1921-07-12');
240+
$this->finalDecisionDateInterval = new ClosedDateInterval('1921-11-07', '1921-11-09');
239241
$this->reportFactory = new ScieloSubmissionsReportFactory($this->application, $this->contextId, $this->sectionsIds, $this->submissionDateInterval, $this->finalDecisionDateInterval, $this->locale, $this->includeViews);
240242
$report = $this->reportFactory->createReport();
241243

@@ -246,7 +248,7 @@ public function testReportFilterByFinalDecisionDateSubmissionAtIntervalStart():
246248

247249
public function testReportFilterByFinalDecisionDateSubmissionAtIntervalEnd(): void
248250
{
249-
$this->finalDecisionDateInterval = new ClosedDateInterval('1921-07-05', '1921-07-10');
251+
$this->finalDecisionDateInterval = new ClosedDateInterval('1921-11-05', '1921-11-07');
250252
$this->reportFactory = new ScieloSubmissionsReportFactory($this->application, $this->contextId, $this->sectionsIds, $this->submissionDateInterval, $this->finalDecisionDateInterval, $this->locale, $this->includeViews);
251253
$report = $this->reportFactory->createReport();
252254

@@ -261,7 +263,7 @@ public function testReportFilterByFinalDecisionDateExcludesSubmissionsWithoutFin
261263
$publicationId = $this->createPublication($submissionWithoutFinalDecisionId, $this->sectionsIds[0]);
262264
$this->addCurrentPublicationToSubmission($submissionWithoutFinalDecisionId, $publicationId);
263265

264-
$this->finalDecisionDateInterval = new ClosedDateInterval('1921-05-20', '1921-07-12');
266+
$this->finalDecisionDateInterval = new ClosedDateInterval('1921-05-20', '1921-11-12');
265267
$this->reportFactory = new ScieloSubmissionsReportFactory($this->application, $this->contextId, $this->sectionsIds, $this->submissionDateInterval, $this->finalDecisionDateInterval, $this->locale, $this->includeViews);
266268
$report = $this->reportFactory->createReport();
267269

@@ -272,7 +274,7 @@ public function testReportFilterByFinalDecisionDateExcludesSubmissionsWithoutFin
272274
public function testReportFilterBySubmissionDateAndFinalDecisionDate(): void
273275
{
274276
$this->submissionDateInterval = new ClosedDateInterval('1921-05-23', '1921-07-01');
275-
$this->finalDecisionDateInterval = new ClosedDateInterval('1921-06-15', '1921-07-12');
277+
$this->finalDecisionDateInterval = new ClosedDateInterval('1921-06-15', '1921-11-12');
276278
$this->reportFactory = new ScieloSubmissionsReportFactory($this->application, $this->contextId, $this->sectionsIds, $this->submissionDateInterval, $this->finalDecisionDateInterval, $this->locale, $this->includeViews);
277279
$report = $this->reportFactory->createReport();
278280

@@ -289,7 +291,7 @@ public function testReportFilterByFinalDecisionDateInOPSGetsPostedSubmissions():
289291
$publicationId = $this->createPublication($postedSubmissionId, $this->sectionsIds[0], '1921-06-21 14:13:20');
290292
$this->addCurrentPublicationToSubmission($postedSubmissionId, $publicationId);
291293

292-
$this->finalDecisionDateInterval = new ClosedDateInterval('1921-05-20', '1921-07-12');
294+
$this->finalDecisionDateInterval = new ClosedDateInterval('1921-05-20', '1921-11-12');
293295
$this->application = 'ops';
294296
$this->reportFactory = new ScieloSubmissionsReportFactory($this->application, $this->contextId, $this->sectionsIds, $this->submissionDateInterval, $this->finalDecisionDateInterval, $this->locale, $this->includeViews);
295297
$report = $this->reportFactory->createReport();

version.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<version>
55
<application>scieloSubmissionsReport</application>
66
<type>plugins.reports</type>
7-
<release>2.4.4.0</release>
8-
<date>2025-03-20</date>
7+
<release>2.4.5.0</release>
8+
<date>2025-04-01</date>
99
<lazy-load>1</lazy-load>
1010
<class>ScieloSubmissionsReportPlugin</class>
1111
</version>

0 commit comments

Comments
 (0)