Skip to content

Commit

Permalink
Invalid Items count on step
Browse files Browse the repository at this point in the history
  • Loading branch information
J0rdyV committed May 30, 2024
1 parent d66de51 commit 61eea59
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Component/Process/ProcessManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ProcessManager
{
private Configuration $configuration;
private ?int $startTimeStamp = null;
private ?int $invalidItems = 0;

public function __construct(Configuration $configuration)
{
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 61eea59

Please sign in to comment.