-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4503fcc
commit beb5958
Showing
5 changed files
with
36 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- metabase-export.sql | ||
-- Ce script est conçu pour être exécuté sur la base de données PostgreSQL de l'instance Metabase (destination). | ||
-- Il consiste à extraire des données de la base applicative (source) pour les charger dans des tables Metabase. | ||
|
||
-- CONNEXION À LA DB APPLICATIVE (source) | ||
-- Voir : https://www.postgresql.org/docs/current/contrib-dblink-connect.html | ||
CREATE EXTENSION IF NOT EXISTS dblink; | ||
SELECT dblink_connect('src', current_setting('custom.src_database_url')); | ||
|
||
-- COLLECTE DES DONNÉES D'INDICATEURS | ||
|
||
-- # Suivi des inscriptions des utilisateurs | ||
-- On stocke dans Metabase un snapshot de la liste des dates d'inscription au moment de l'exécution | ||
-- On va donc recréer la table en entier. | ||
DROP TABLE IF EXISTS analytics_user_registration; | ||
|
||
CREATE TABLE analytics_user_registration AS | ||
SELECT | ||
uuid_generate_v4() AS id, | ||
t1.registration_date | ||
FROM dblink('src', 'SELECT registration_date FROM "user"') AS t1(registration_date); | ||
|
||
ALTER TABLE analytics_user_registration ADD PRIMARY KEY (id); |