From 54805eda2cab0ae32c74853056f5f09f482ee2aa Mon Sep 17 00:00:00 2001 From: ajmahoney Date: Mon, 16 Mar 2020 11:15:23 +0000 Subject: [PATCH 1/2] Chunks if possible (#1) --- src/Fogger/Data/ChunkProducer.php | 12 +++++++++++- src/Fogger/Recipe/RecipeTableFactory.php | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Fogger/Data/ChunkProducer.php b/src/Fogger/Data/ChunkProducer.php index 257bf9e..1422031 100644 --- a/src/Fogger/Data/ChunkProducer.php +++ b/src/Fogger/Data/ChunkProducer.php @@ -41,14 +41,24 @@ private function queueTableChunks(Table $table) $counter = 0; $keys = []; + $last_key = null; - while ($key = $result->fetchColumn()) { + while (($key = $result->fetchColumn()) !== False) { $keys[] = $key; $counter++; if (0 === $counter % $table->getChunkSize()) { + + do { + $last_key = $key; + $key = $result->fetchColumn(); + $counter++; + } while ($last_key === $key); + $this->chunkCache->pushMessage($table, $keys); $keys = []; + $keys[] = $key; } + $last_key = $key; } if (0 !== $counter % $table->getChunkSize()) { $this->chunkCache->pushMessage($table, $keys); diff --git a/src/Fogger/Recipe/RecipeTableFactory.php b/src/Fogger/Recipe/RecipeTableFactory.php index ff3bdce..a4749e8 100644 --- a/src/Fogger/Recipe/RecipeTableFactory.php +++ b/src/Fogger/Recipe/RecipeTableFactory.php @@ -32,6 +32,14 @@ private function findSortBy(DBAL\Table $table): ?string return $index->getColumns()[0]; } } + if ($table->getPrimaryKey()) { + return $table->getPrimaryKeyColumns()[0]; + } + foreach ($table->getIndexes() as $index) { + if ($index->isUnique()) { + return $index->getColumns()[0]; + } + } return null; } From eab3bfc1059d76e6781214a78ff9dbb5d6fad5ca Mon Sep 17 00:00:00 2001 From: Andy Mahoney Date: Mon, 16 Mar 2020 10:08:58 +0000 Subject: [PATCH 2/2] Add EchoMask masker --- src/Fogger/Mask/EchoMask.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/Fogger/Mask/EchoMask.php diff --git a/src/Fogger/Mask/EchoMask.php b/src/Fogger/Mask/EchoMask.php new file mode 100644 index 0000000..61a0e8b --- /dev/null +++ b/src/Fogger/Mask/EchoMask.php @@ -0,0 +1,20 @@ +