Skip to content

Commit

Permalink
Merge pull request #102 from Progi1984/optimizeImport
Browse files Browse the repository at this point in the history
Doctrine : Optimize import with batch processing
  • Loading branch information
Progi1984 authored Jan 17, 2024
2 parents 8304ba6 + b6d451b commit 456d0dc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:

- name: Inject data for AutoUpgrade
run: |
DATE=$(date -d "2 days ago" +"%Y-%m-%d")
DATE=$(date -d "1 day ago" +"%Y-%m-%d")
php bin/console nightly:import \
-p cli \
-c autoupgrade \
Expand All @@ -109,7 +109,7 @@ jobs:
- name: Inject data for Core
run: |
DATE=$(date -d "2 days ago" +"%Y-%m-%d")
DATE=$(date -d "1 day ago" +"%Y-%m-%d")
php bin/console nightly:import \
-p chromium \
-c functional \
Expand Down
8 changes: 8 additions & 0 deletions src/Service/ReportImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function import(
;
$this->entityManager->persist($execution);
$this->entityManager->flush();
$executionId = $execution->getId();

if ($dateformat == self::FORMAT_DATE_MOCHA5) {
$this->insertExecutionSuite($execution, $jsonContent->suites, $dateformat);
Expand All @@ -71,12 +72,16 @@ public function import(
if ($suite->root) {
foreach ($suite->suites as $suiteChild) {
$this->insertExecutionSuite($execution, $suiteChild, $dateformat);
// Reload of execution (bcz insertExecutionSuite make a Doctrine Clear)
$execution = $this->executionRepository->findOneBy(['id' => $executionId]);
}
} else {
$this->insertExecutionSuite($execution, $suite, $dateformat);
}
}
}
// Reload of execution (bcz insertExecutionSuite make a Doctrine Clear)
$execution = $this->executionRepository->findOneBy(['id' => $executionId]);

// Calculate comparison with last execution
$execution = $this->compareReportData($execution);
Expand Down Expand Up @@ -144,6 +149,9 @@ private function insertExecutionSuite(Execution $execution, \stdClass $suite, st
foreach ($suite->suites as $suiteChildren) {
$this->insertExecutionSuite($execution, $suiteChildren, $dateFormat, $executionSuite->getId());
}
if (!$parentSuiteId) {
$this->entityManager->clear();
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/ImportControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ImportControllerTest extends WebTestCase

public static function setUpBeforeClass(): void
{
self::$date = date('Y-m-d', strtotime('yesterday'));
self::$date = date('Y-m-d', strtotime('today'));
}

public function testOldReportWithNoParameters(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/ReportControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static function setUpBeforeClass(): void
{
$data = file_get_contents('https://api-nightly.prestashop-project.org/reports?filter_version=develop&filter_campaign=functional');
$data = json_decode($data, true);
self::$reportId = $data[2]['id'];
self::$reportId = $data[1]['id'];

$data = file_get_contents('https://api-nightly.prestashop-project.org/reports/' . self::$reportId);
$data = json_decode($data, true);
Expand Down

0 comments on commit 456d0dc

Please sign in to comment.