Skip to content

Commit

Permalink
perf(export): improve performance of exporter
Browse files Browse the repository at this point in the history
- use LazyCollectionLoader to prevent memory errors when loading when fetching a big collection
- deactivate time limit for ExportAction (huge collection exports will probably take more than the default 30 seconds to export)
  • Loading branch information
JoelAlphonso committed Jun 16, 2022
1 parent 686cb23 commit 1919281
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Charcoal/Admin/Action/Object/ExportAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class ExportAction extends AdminAction
*/
public function run(RequestInterface $request, ResponseInterface $response)
{
set_time_limit(0);

$failMessage = $this->translator()->translation('Failed to export object(s)');
$errorThrown = strtr($this->translator()->translation('{{ errorMessage }}: {{ errorThrown }}'), [
'{{ errorMessage }}' => $failMessage
Expand Down
4 changes: 2 additions & 2 deletions src/Charcoal/Admin/Service/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use League\Csv\Writer;

// From 'charcoal-core'
use Charcoal\Loader\CollectionLoader;
use Charcoal\Loader\LazyCollectionLoader;

// From 'charcoal-factory'
use Charcoal\Factory\FactoryInterface;
Expand Down Expand Up @@ -185,7 +185,7 @@ public function collection()
));
}

$collection = new CollectionLoader([
$collection = new LazyCollectionLoader([
'logger' => $this->logger,
'factory' => $this->modelFactory()
]);
Expand Down

0 comments on commit 1919281

Please sign in to comment.