This commit is contained in:
2025-09-18 07:48:51 +02:00
parent b131af5a82
commit a413a5173d
6 changed files with 134 additions and 22 deletions

View File

@@ -41,6 +41,33 @@ services:
superset run -h 0.0.0.0 -p 8088 --with-threads --reload --debugger
"
metabase:
image: metabase/metabase:v0.56.5.5
depends_on:
database:
condition: service_healthy
volumes:
- /dev/urandom:/dev/random:ro
ports:
- "3000:3000"
environment:
MB_DB_TYPE: postgres
MB_DB_HOST: ${MB_DB_HOST:-database}
MB_DB_PORT: 5432
MB_DB_USER: metabase_user
MB_DB_PASS: ${DB_ROOT_PASSWORD:-supermotdepasse}
MB_DB_DBNAME: metabase
MB_SITE_LOCALE: fr
MB_ADMIN_EMAIL: etudiant@univ-lorraine.fr
MB_ANON_TRACKING_ENABLED: false
MB_CHECK_FOR_UPDATES: false
MB_NO_SURVEYS: yes
MB_START_OF_WEEK: monday
MB_CUSTOM_FORMATTING: '{"type/Temporal":{"time_style":"HH:mm","date_style":"D MMMM, YYYY","date_abbreviate":true},"type/Currency":{"currency":"EUR"},"type/Number":{"number_separators":", "}}'
MB_EMAIL_SMTP_HOST: mailpit
MB_EMAIL_SMTP_PORT: 1025
MB_EMAIL_FROM_ADDRESS: metabase@univ-lorraine.fr
# CouchDB
# Single-node document database
# https://couchdb.apache.org/

View File

@@ -65,24 +65,3 @@ create table region (
insert into region values
(1, 'Est'), (2, 'Ouest');
-- Apache Superset
create database superset;
create user superset with password 'supermotdepasse';
grant all privileges on database superset to superset;
grant connect on database sql to superset;
grant usage on schema public to superset;
grant select on table famille, article to superset;
-- Pour toutes les tables dun schéma existant
grant select on all tables in schema public to superset;
-- Privilège par défaut pour que chaque nouvelle table créée dans public donnera automatiquement le droit SELECT à superset.
alter default privileges in schema public
grant select on tables to superset;
\c superset
alter schema public owner to superset;
grant all privileges on schema public to superset;

View File

@@ -9,3 +9,23 @@ create view nb_total_tickets as
create view nb_total_adherents as
select count(*) as nb_total_adherents from adherent;
create materialized view detail_ticket as
select t.id as ticket_id, t.date_ticket, t.mode_rglt,
h.id as adherent_id, h.codepostal, h.genre,
round(sum(l.total), 2) as total
from ticket t
join ligne l on l.ticket_id = t.id
join adherent h on h.id = t.adherent_id
group by t.id, h.id;
create materialized view detail_vente as
select t.id as ticket_id, t.date_ticket, t.mode_rglt,
h.id as adherent_id, h.codepostal, h.genre,
l.article_code, a.famille_code,
round(sum(l.total), 2) as total
from ticket t
join ligne l on l.ticket_id = t.id
join adherent h on h.id = t.adherent_id
join article a on a.code = l.article_code
group by t.id, h.id, l.article_code, a.famille_code;

View File

@@ -0,0 +1,43 @@
-- Metabase
create role metabase_user with
login
nosuperuser
nocreatedb
nocreaterole
noinherit
noreplication
connection limit -1
password 'supermotdepasse';
create database metabase with
owner metabase_user;
grant connect
on database metabase
to metabase_user;
grant connect
on database sql
to metabase_user;
grant usage
on schema public
to metabase_user;
grant select
on table famille, article
to metabase_user;
-- Pour toutes les tables du schéma public
grant select
on all tables
in schema public
to metabase_user;
-- Privilège par défaut pour que chaque nouvelle table créée dans public donnera automatiquement le droit SELECT à metabase.
alter default privileges
in schema public
grant select
on tables
to metabase_user;

View File

@@ -0,0 +1,43 @@
-- Apache Superset
create role superset_user with
login
nosuperuser
nocreatedb
nocreaterole
noinherit
noreplication
connection limit -1
password 'supermotdepasse';
create database superset with
owner superset_user;
grant connect
on database superset
to superset_user;
grant connect
on database sql
to superset_user;
grant usage
on schema public
to superset_user;
grant select
on table famille, article
to superset_user;
-- Pour toutes les tables du schéma public
grant select
on all tables
in schema public
to superset_user;
-- Privilège par défaut pour que chaque nouvelle table créée dans public donnera automatiquement le droit SELECT à superset_user.
alter default privileges
in schema public
grant select
on tables
to superset_user;

View File

@@ -43,7 +43,7 @@ create table route_cout (
);
create table zone (
id int primary key generated always as identity,
id int primary key,
nom text,
categorie text,
geom geometry(polygon, 4326) -- on choisit srid 4326 (wgs84)