Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrige l'export Metabase : DATABASE_URL manquant, uuid d'utilisateur actif incorrect #1134

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,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
./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
2 changes: 1 addition & 1 deletion docs/tools/metabase.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ La configuration de la GitHub Action passe par diverses variables d'environnemen
| Variable d'environnement | Configuration | Description |
|---|---|---|
| `METABASE_MIGRATIONS_METABASE_DATABASE_URL` | [Secret](https://docs.github.com/fr/actions/security-guides/using-secrets-in-github-actions) au sens GitHub Actions | L'URL d'accès à la base de données Metabase par la CI, afin d'exécuter les migrations (`./tools/scalingodbtunnel dialog-metabase --host-url --port 10001`) |
| `METABASE_EXPORT_DATABASE_URL` | [Secret](https://docs.github.com/fr/actions/security-guides/using-secrets-in-github-actions) au sens GitHub Actions | L'URL d'accès à la base de données applicative par la CI (`./tools/scalingodbtunnel dialog --host-url --port 10001`) |
| `METABASE_EXPORT_DATABASE_URL` | [Secret](https://docs.github.com/fr/actions/security-guides/using-secrets-in-github-actions) au sens GitHub Actions | L'URL d'accès à la base de données applicative par la CI (`./tools/scalingodbtunnel dialog --host-url --port 10000`) |
| `METABASE_EXPORT_METABASE_DATABASE_URL` | Secret | L'URL d'accès à la base de données Metabase par la CI (`./tools/scalingodbtunnel dialog-metabase --host-url --port 10001`) |
| `GH_SCALINGO_SSH_PRIVATE_KEY` | Secret | Clé SSH privée permettant l'accès à Scalingo par la CI |
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 @@ -60,5 +60,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();
}
}
Loading