From 61eea599443c1bdbd16e8256647baea856515f4b Mon Sep 17 00:00:00 2001 From: J0rdyV <28193980+J0rdyV@users.noreply.github.com> Date: Thu, 30 May 2024 14:35:50 +0200 Subject: [PATCH] Invalid Items count on step --- src/Component/Process/ProcessManager.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Component/Process/ProcessManager.php b/src/Component/Process/ProcessManager.php index fa8d8c72..4a4e8bb9 100644 --- a/src/Component/Process/ProcessManager.php +++ b/src/Component/Process/ProcessManager.php @@ -9,6 +9,7 @@ class ProcessManager { private Configuration $configuration; private ?int $startTimeStamp = null; + private ?int $invalidItems = 0; public function __construct(Configuration $configuration) { @@ -34,6 +35,9 @@ public function startProcess(): void $amount = -1; } + $path = $this->configuration->getContext('workpath').'/invalid_items.csv'; + $this->invalidItems = $this->getLines($path); + if ($pipeline = $this->configuration->getPipeline()) { if ($debug === true) { if ($mappings === true) { @@ -67,11 +71,27 @@ public function stopProcess(): void $executionTime = round($stopTimeStamp - $this->startTimeStamp, 1); $executionTime = "Execution Time: {$executionTime}s"; + $path = $this->configuration->getContext('workpath').'/invalid_items.csv'; + $this->invalidItems = $this->getLines($path) - $this->invalidItems; + $invalidItems = "Invalid Items: $this->invalidItems"; + $this->log(sprintf( - "Finished Step :: %s (%s, %s)", + "Finished Step :: %s (%s, %s, %s)", basename($this->configuration->getContext('transformation_file')), $usage, - $executionTime + $executionTime, + $invalidItems )); } + + private function getLines($file): int + { + $f = fopen($file, 'rb'); + $lines = 0; + while (!feof($f)) { + $lines += substr_count(fread($f, 8192), "\n"); + } + fclose($f); + return $lines; + } } \ No newline at end of file