diff --git a/Makefile b/Makefile index c7cf73be7..4107f17c2 100644 --- a/Makefile +++ b/Makefile @@ -295,7 +295,7 @@ ci_metabase_migrate: ## Run CI steps for Metabase Migrate workflow ci_metabase_export: ## Export data to Metabase make composer CMD="install -n --prefer-dist" - scalingo login --ssh --ssh-identity ~/.ssh/id_rsa + scalingo login --ssh --ssh-identity ~/.ssh/id_ed25519 ./tools/scalingodbtunnel dialog --host-url --port 10000 & ./tools/wait-for-it.sh 127.0.0.1:10000 ./tools/scalingodbtunnel dialog-metabase --host-url --port 10001 & ./tools/wait-for-it.sh 127.0.0.1:10001 make console CMD="app:metabase:export" diff --git a/src/Infrastructure/Persistence/Doctrine/Repository/Statistics/StatisticsRepository.php b/src/Infrastructure/Persistence/Doctrine/Repository/Statistics/StatisticsRepository.php index 052404bb7..f011a8622 100644 --- a/src/Infrastructure/Persistence/Doctrine/Repository/Statistics/StatisticsRepository.php +++ b/src/Infrastructure/Persistence/Doctrine/Repository/Statistics/StatisticsRepository.php @@ -65,7 +65,7 @@ private function bulkInsertUserActiveStatistics(\DateTimeInterface $now, array $ foreach ($userRows as $row) { $stmt->bindValue('id', $row['uuid']); $stmt->bindValue('uploadedAt', $now->format(\DateTimeInterface::ATOM)); - $stmt->bindValue('lastActiveAt', $row['lastActiveAt']?->format(\DateTimeInterface::ATOM)); + $stmt->bindValue('lastActiveAt', $row['last_active_at']); $stmt->execute(); } } diff --git a/src/Infrastructure/Persistence/Doctrine/Repository/User/UserRepository.php b/src/Infrastructure/Persistence/Doctrine/Repository/User/UserRepository.php index fb8902e30..e2e4026af 100644 --- a/src/Infrastructure/Persistence/Doctrine/Repository/User/UserRepository.php +++ b/src/Infrastructure/Persistence/Doctrine/Repository/User/UserRepository.php @@ -51,9 +51,11 @@ public function countUsers(): int public function findAllForStatistics(): array { - return $this->createQueryBuilder('u') - ->select('u.uuid, u.lastActiveAt') - ->getQuery() - ->getResult(); + return $this->getEntityManager() + ->getConnection() + ->fetchAllAssociative( + 'SELECT uuid_generate_v4() AS uuid, u.last_active_at AS last_active_at + FROM "user" AS u', + ); } } diff --git a/tests/Integration/Infrastructure/Symfony/Command/RunMetabaseExportCommandTest.php b/tests/Integration/Infrastructure/Symfony/Command/RunMetabaseExportCommandTest.php index a5c151e7e..35fc17b30 100644 --- a/tests/Integration/Infrastructure/Symfony/Command/RunMetabaseExportCommandTest.php +++ b/tests/Integration/Infrastructure/Symfony/Command/RunMetabaseExportCommandTest.php @@ -10,6 +10,9 @@ final class RunMetabaseExportCommandTest extends KernelTestCase { + /** + * @group only + */ public function testExecute(): void { self::bootKernel(); @@ -60,5 +63,9 @@ public function testExecute(): void $this->assertSame('2023-06-09 00:00:00', $rows[2]['uploaded_at']); $this->assertSame(null, $rows[2]['last_active_at']); + + // Execute again to test for uuid conflicts + $commandTester->execute([]); + $commandTester->assertCommandIsSuccessful(); } }