Fix various import bugs.

This commit is contained in:
James Cole
2017-06-24 08:37:09 +02:00
parent da3a56c144
commit 8e3ba7caf2
8 changed files with 25 additions and 22 deletions

View File

@@ -99,6 +99,13 @@ class CsvConfigurator implements ConfiguratorInterface
*/
public function isJobConfigured(): bool
{
$config = $this->job->configuration;
$config['initial-config-complete'] = $config['initial-config-complete'] ?? false;
$config['column-roles-complete'] = $config['column-roles-complete'] ?? false;
$config['column-mapping-complete'] = $config['column-mapping-complete'] ?? false;
$this->job->configuration = $config;
$this->job->save();
if ($this->job->configuration['initial-config-complete']
&& $this->job->configuration['column-roles-complete']
&& $this->job->configuration['column-mapping-complete']

View File

@@ -70,7 +70,6 @@ class CsvProcessor implements FileProcessorInterface
$index = 0;
Log::notice('Building importable objects from CSV file.');
foreach ($entries as $index => $row) {
sleep(1);
// verify if not exists already:
if ($this->rowAlreadyImported($row)) {
$message = sprintf('Row #%d has already been imported.', $index);
@@ -198,8 +197,6 @@ class CsvProcessor implements FileProcessorInterface
->where('data', $json)
->where('name', 'importHash')
->first();
return rand(1, 10) === 3;
if (!is_null($entry)) {
return true;
}

View File

@@ -58,13 +58,13 @@ class ImportRoutine
return false;
}
set_time_limit(0);
Log::debug(sprintf('Start with import job %s', $this->job->key));
Log::info(sprintf('Start with import job %s', $this->job->key));
$importObjects = $this->getImportObjects();
$this->lines = $importObjects->count();
// once done, use storage thing to actually store them:
Log::debug(sprintf('Returned %d valid objects from file processor', $this->lines));
Log::info(sprintf('Returned %d valid objects from file processor', $this->lines));
$storage = $this->storeObjects($importObjects);
@@ -78,7 +78,7 @@ class ImportRoutine
// create tag, link tag to all journals:
$this->createImportTag();
Log::debug(sprintf('Done with import job %s', $this->job->key));
Log::info(sprintf('Done with import job %s', $this->job->key));
return true;
}

View File

@@ -97,7 +97,6 @@ class ImportStorage
{
$this->defaultCurrency = Amount::getDefaultCurrencyByUser($this->job->user);
// routine below consists of 3 steps.
/**
* @var int $index
@@ -283,10 +282,8 @@ class ImportStorage
private function storeImportJournal(int $index, ImportJournal $importJournal): bool
{
sleep(1);
Log::debug(sprintf('Going to store object #%d with description "%s"', $index, $importJournal->description));
$errors = new MessageBag;
$asset = $importJournal->asset->getAccount();
$amount = $importJournal->getAmount();
$currency = $this->getCurrency($importJournal);
@@ -354,7 +351,6 @@ class ImportStorage
$this->job->addStepsDone(1);
$this->journals->push($journal);
$this->errors->push($errors);
return true;
}