Skip to content

Commit

Permalink
Merge pull request #20 from DivanteLtd/feature/analysis-fix
Browse files Browse the repository at this point in the history
Feature/analysis fix
  • Loading branch information
bramalho authored Oct 11, 2020
2 parents cf232e4 + 71c9bd4 commit 8e1885f
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 2,866 deletions.
59 changes: 0 additions & 59 deletions .github/workflows/tests.yml

This file was deleted.

7 changes: 2 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Scheduled Export
[![Analysis Actions](https://github.com/DivanteLtd/pimcore-scheduled-export/workflows/Analysis/badge.svg?branch=master)](https://github.com/DivanteLtd/pimcore-scheduled-export/actions)
[![Tests Actions](https://github.com/DivanteLtd/pimcore-scheduled-export/workflows/Tests/badge.svg?branch=master)](https://github.com/DivanteLtd/pimcore-scheduled-export/actions)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2c51a42a456c47c9971a7e2a48bcd6f4)](https://www.codacy.com/app/Divante/pimcore-scheduled-export?utm_source=github.com&utm_medium=referral&utm_content=DivanteLtd/pimcore-scheduled-export&utm_campaign=Badge_Grade)
[![Latest Stable Version](https://poser.pugx.org/divante-ltd/pimcore-scheduled-export/v/stable)](https://packagist.org/packages/divante-ltd/pimcore-scheduled-export)
[![Total Downloads](https://poser.pugx.org/divante-ltd/pimcore-scheduled-export/downloads)](https://packagist.org/packages/divante-ltd/pimcore-scheduled-export)
Expand All @@ -24,7 +23,7 @@ Scheduled Export lets you run ordinary grid exports in the background or using c

## Compatibility

This module is compatible with Pimcore 5.5.0 and higher.
This module is compatible with Pimcore 6.3.0 and higher.

## Installing

Expand All @@ -34,7 +33,6 @@ composer require divante-ltd/pimcore-scheduled-export

Make sure the dependencies are enabled and installed:
```bash
./bin/console pimcore:bundle:enable PimcoreDevkitBundle
./bin/console pimcore:bundle:enable ProcessManagerBundle
./bin/console pimcore:bundle:install ProcessManagerBundle
```
Expand All @@ -46,8 +44,7 @@ Enable the Bundle:

## Requirements

* Pimcore 5 or 6
* Pimcore Devkit
* Pimcore 6.3
* ProcessManager

## Usage
Expand Down
34 changes: 19 additions & 15 deletions src/ScheduledExportBundle/Export/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,9 @@ class Export

/**
* Export constructor.
* @param string $gridConfig
* @param string $objectsFolder
* @param string $assetFolder
* @param ContainerInterface $container
* @param string|null $condition
* @param string|null $fileName
* @param string $timestamp
* @param string $onlyChanges
* @param $input
* @param $output
* @throws \Exception
*/
public function __construct(
Expand Down Expand Up @@ -106,6 +101,9 @@ public function __construct(
$this->types = str_replace(' ', '', (string) $input->getOption("types"));
}

/**
* @return WebsiteSetting
*/
public function getExportSetting() : WebsiteSetting
{
$settings = WebsiteSetting::getByName($this->gridConfig->getId() .
Expand Down Expand Up @@ -239,7 +237,7 @@ public function getTimestampFormat(): string
}

/**
* @param mixed $timestampFormat
* @param string $timestampFormat
*/
public function setTimestampFormat(string $timestampFormat): void
{
Expand Down Expand Up @@ -287,11 +285,13 @@ public function export(): void
}
}
$this->process->progress(count($objectIdBatch));
$this->process->setMessage(sprintf("Running (%d/%d)", $this->process->getProgress(), $this->process->getTotal()));
$this->process->setMessage(
sprintf("Running (%d/%d)", $this->process->getProgress(), $this->process->getTotal())
);
$this->process->save();
\Pimcore::collectGarbage();

}

$this->process->setMessage("Saving results");
$this->process->save();
$this->saveFileInAssets($filenames);
Expand All @@ -305,6 +305,8 @@ public function export(): void
}

/**
* @param array $objectIds
* @param string $filename
* @return Request
*/
protected function prepareRequest(array $objectIds, string $filename): Request
Expand Down Expand Up @@ -360,7 +362,7 @@ protected function prepareListing(): void
protected function getObjectIds(): array
{
$objectIds = [];
for($i = 0; $i <= $this->process->getTotal(); $i = $i + self::INTERNAL_BATCH_SIZE) {
for ($i = 0; $i <= $this->process->getTotal(); $i = $i + self::INTERNAL_BATCH_SIZE) {
$this->listing->setOffset($i);
$this->listing->setLimit(self::INTERNAL_BATCH_SIZE);
$objectIds[] = $this->listing->loadIdList();
Expand Down Expand Up @@ -407,7 +409,9 @@ protected function setHelperColumnsInSession($fieldsRaw): void
}

/**
* @param array $filenames
* @return void
* @throws \Exception
*/
protected function saveFileInAssets(array $filenames): void
{
Expand All @@ -427,14 +431,14 @@ protected function saveFileInAssets(array $filenames): void
$firstFile = false;
}

if($this->input->getOption('divide_file')) {
if ($this->input->getOption('divide_file')) {
$line = strtok($content, $separator);
$header = $line;
$counter = 0;
$fileCounter = 0;
$subContent = "";
while ($line !== false) {
$line = strtok( $separator );
$line = strtok($separator);
$subContent .= $line . "\r\n";
$counter++;
if ($counter % $this->input->getOption('divide_file') == 0) {
Expand All @@ -456,14 +460,14 @@ protected function saveFileInAssets(array $filenames): void
$assetFile->setData($content);
$assetFile->save();
}

}

/**
* @param string $assetFolder
* @param int|null $index
* @return Asset
*/
protected function prepareAssetFile($assetFolder, ?int $index = null): Asset
protected function prepareAssetFile(string $assetFolder, ?int $index = null): Asset
{
$assetFile = new Asset();

Expand Down
26 changes: 0 additions & 26 deletions tests/_support/FunctionalTester.php

This file was deleted.

10 changes: 0 additions & 10 deletions tests/_support/Helper/Functional.php

This file was deleted.

Loading

0 comments on commit 8e1885f

Please sign in to comment.