} /** @var list<string> $affectedCustomers */
$affectedCustomers =
array_filter($this->connection->
fetchFirstColumn( 'SELECT DISTINCT(`customer_id`) FROM product_review WHERE id IN (:ids)',
['ids' => Uuid::
fromHexToBytesList($reviewIds)],
['ids' => ArrayParameterType::STRING
] ));
foreach ($affectedCustomers as $customerId) { $this->
updateReviewCountForCustomer($customerId);
} } public function updateReviewCountForCustomer(string
$customerId): void
{ $this->connection->
executeStatement( 'UPDATE `customer` SET review_count = (
SELECT COUNT(*) FROM `product_review` WHERE `customer_id` = :id AND `status` = 1
) WHERE id = :id',
['id' =>
$customerId] );
}