Skip to content

Commit

Permalink
Fix user active id generation
Browse files Browse the repository at this point in the history
  • Loading branch information
florimondmanca committed Jan 7, 2025
1 parent f01b9a5 commit 0a0ad67
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

final class RunMetabaseExportCommandTest extends KernelTestCase
{
/**
* @group only
*/
public function testExecute(): void
{
self::bootKernel();
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 0a0ad67

Please sign in to comment.