diff --git a/src/Components/RefundManager/Elasticsearch/RefundAdminSearchIndexer.php b/src/Components/RefundManager/Elasticsearch/RefundAdminSearchIndexer.php new file mode 100644 index 000000000..b40756389 --- /dev/null +++ b/src/Components/RefundManager/Elasticsearch/RefundAdminSearchIndexer.php @@ -0,0 +1,91 @@ +factory->createIterator($this->getEntity(), null, $this->indexingBatchSize); + } + + public function fetch(array $ids): array + { + $data = $this->connection->fetchAllAssociative( + ' + SELECT LOWER(HEX(mollie_refund.id)) as id, + type, + public_description, + internal_description, + + FROM mollie_refund + WHERE mollie_refund.id IN (:ids) + GROUP BY mollie_refund.id + ', + [ + 'ids' => Uuid::fromHexToBytesList($ids), + ], + [ + 'ids' => ArrayParameterType::BINARY, + ] + ); + + $mapped = []; + foreach ($data as $row) { + $id = (string) $row['id']; + $text = \implode(' ', array_filter($row)); + $mapped[$id] = ['id' => $id, 'text' => \strtolower($text)]; + } + + return $mapped; + } + + public function globalData(array $result, Context $context): array + { + $ids = array_column($result['hits'], 'id'); + + return [ + 'total' => (int) $result['total'], + 'data' => $this->repository->search(new Criteria($ids), $context)->getEntities(), + ]; + } +} diff --git a/src/Components/Subscription/Elasticsearch/SubscriptionAdminSearchIndexer.php b/src/Components/Subscription/Elasticsearch/SubscriptionAdminSearchIndexer.php new file mode 100644 index 000000000..744b4d8fa --- /dev/null +++ b/src/Components/Subscription/Elasticsearch/SubscriptionAdminSearchIndexer.php @@ -0,0 +1,95 @@ +factory->createIterator($this->getEntity(), null, $this->indexingBatchSize); + } + + public function fetch(array $ids): array + { + $data = $this->connection->fetchAllAssociative( + ' + SELECT LOWER(HEX(mollie_subscription.id)) as id, + mollie_id, + mollie_customer_id, + description, + next_payment_at, + last_reminded_at, + canceled_at, + mandate_id, + status + FROM mollie_subscription + WHERE mollie_subscription.id IN (:ids) + GROUP BY mollie_subscription.id + ', + [ + 'ids' => Uuid::fromHexToBytesList($ids), + ], + [ + 'ids' => ArrayParameterType::BINARY, + ] + ); + + $mapped = []; + foreach ($data as $row) { + $id = (string) $row['id']; + $text = \implode(' ', array_filter($row)); + $mapped[$id] = ['id' => $id, 'text' => \strtolower($text)]; + } + + return $mapped; + } + + public function globalData(array $result, Context $context): array + { + $ids = array_column($result['hits'], 'id'); + + return [ + 'total' => (int) $result['total'], + 'data' => $this->repository->search(new Criteria($ids), $context)->getEntities(), + ]; + } +} diff --git a/src/Resources/config/services/refundmanager/services.xml b/src/Resources/config/services/refundmanager/services.xml index 3e6ae3a34..9c631caff 100644 --- a/src/Resources/config/services/refundmanager/services.xml +++ b/src/Resources/config/services/refundmanager/services.xml @@ -19,5 +19,16 @@ + + + + + + %elasticsearch.indexing_batch_size% + + + + + diff --git a/src/Resources/config/services/subscription/services.xml b/src/Resources/config/services/subscription/services.xml index 4e07bfcea..28bcafe53 100755 --- a/src/Resources/config/services/subscription/services.xml +++ b/src/Resources/config/services/subscription/services.xml @@ -293,5 +293,15 @@ + + + + + %elasticsearch.indexing_batch_size% + + + + +