Set CLI message when flushing

This commit is contained in:
Sebastian Meyer 2024-02-01 15:58:48 +01:00
parent 9dcbbdaf69
commit 98c8325db3
1 changed files with 2 additions and 1 deletions

View File

@ -161,10 +161,11 @@ class CsvImportCommand extends Console
++$count; ++$count;
$progressIndicator->advance(); $progressIndicator->advance();
$progressIndicator->setMessage('Importing... ' . (string) $count . ' records done.'); $progressIndicator->setMessage('Importing... ' . (string) $count . ' records processed.');
// Flush to database if memory usage reaches limit or every 50.000 records. // Flush to database if memory usage reaches limit or every 50.000 records.
if ((memory_get_usage() / $phpMemoryLimit) > $memoryLimit || ($count % 50000) === 0) { if ((memory_get_usage() / $phpMemoryLimit) > $memoryLimit || ($count % 50000) === 0) {
$progressIndicator->setMessage('Importing... ' . (string) $count . ' records processed. Flushing to database...');
Database::getInstance()->flush([Record::class]); Database::getInstance()->flush([Record::class]);
} }
} }