Commit e789edc1 authored by Stephane Crozat's avatar Stephane Crozat
Browse files

Ajout du niveau : répertoire data, fichier CSV à ajouter dans la procédure...

Ajout du niveau : répertoire data, fichier CSV à ajouter dans la procédure d'INSTALL, modif SQL et PHP pour afficher le niveau
parent f6ec0afb
# PostgreSQL # PostgreSQL
## Add external data
add student.csv to data
## Create user and db ## Create user and db
sudo su postgres sudo su postgres
sql/db_init.sh sql (give access to postgres user, and password first) sql/db_init.sh password
## Test ## Test
psql -h localhost -U apisub -d apisub psql -h localhost -U apisub -d apisub
......
*
!.gitignore
...@@ -64,10 +64,10 @@ class Views { ...@@ -64,10 +64,10 @@ class Views {
private function printStudent($row) { private function printStudent($row) {
if (!$row['surname']) { if (!$row['surname']) {
return "$row[utclogin]"; return "$row[utclogin] $row[level]";
} }
else { else {
return "$row[firstname] $row[surname] ($row[email])"; return "$row[firstname] $row[surname] $row[level] (<a href='mailto:$row[email]'>[mail]</a>)";
} }
} }
......
CREATE TABLE student (
utclogin TEXT PRIMARY KEY,
level TEXT
);
...@@ -16,6 +16,8 @@ INSERT INTO localuser (utclogin) VALUES ('icaillea'); ...@@ -16,6 +16,8 @@ INSERT INTO localuser (utclogin) VALUES ('icaillea');
INSERT INTO localuser (utclogin) VALUES ('ramond'); INSERT INTO localuser (utclogin) VALUES ('ramond');
INSERT INTO localuser (utclogin) VALUES ('baouchya'); INSERT INTO localuser (utclogin) VALUES ('baouchya');
INSERT INTO localuser (utclogin) VALUES ('syrousse'); INSERT INTO localuser (utclogin) VALUES ('syrousse');
INSERT INTO localuser (utclogin) VALUES ('amaldona');
INSERT INTO localuser (utclogin) VALUES ('huetremy');
INSERT INTO api ( id, dbegin, code, name, description, duration, size, ects, resplogin) VALUES ( INSERT INTO api ( id, dbegin, code, name, description, duration, size, ects, resplogin) VALUES (
...@@ -90,10 +92,10 @@ INSERT INTO api VALUES ( ...@@ -90,10 +92,10 @@ INSERT INTO api VALUES (
INSERT INTO subscribe (utclogin,api,subdate) VALUES ( INSERT INTO subscribe (utclogin,api,subdate) VALUES (
'dore','5e06e8dc-2178-11e9-8edb-4bc5e8f8599c',TO_DATE('20190121','yyyymmdd') 'huetremy','5e06e8dc-2178-11e9-8edb-4bc5e8f8599c',TO_DATE('20190121','yyyymmdd')
); );
INSERT INTO subscribe (utclogin,api,subdate) VALUES ( INSERT INTO subscribe (utclogin,api,subdate) VALUES (
'sdesterc','5e06e8dc-2178-11e9-8edb-4bc5e8f8599c',TO_DATE('20190121','yyyymmdd') 'amaldona','5e06e8dc-2178-11e9-8edb-4bc5e8f8599c',TO_DATE('20190121','yyyymmdd')
); );
INSERT INTO subscribe (utclogin,api,subdate) VALUES ( INSERT INTO subscribe (utclogin,api,subdate) VALUES (
'nsalzman','5e06e8dc-2178-11e9-8edb-4bc5e8f8599c',TO_DATE('20190121','yyyymmdd') 'nsalzman','5e06e8dc-2178-11e9-8edb-4bc5e8f8599c',TO_DATE('20190121','yyyymmdd')
......
...@@ -9,9 +9,7 @@ CREATE TABLE localuser ( ...@@ -9,9 +9,7 @@ CREATE TABLE localuser (
utclogin TEXT PRIMARY KEY, utclogin TEXT PRIMARY KEY,
email TEXT, email TEXT,
surname TEXT, surname TEXT,
firstname TEXT, firstname TEXT
speciality TEXT,
level TEXT
); );
CREATE TABLE api ( CREATE TABLE api (
...@@ -45,12 +43,4 @@ CREATE TABLE subscribe ( ...@@ -45,12 +43,4 @@ CREATE TABLE subscribe (
PRIMARY KEY (utclogin,api) PRIMARY KEY (utclogin,api)
); );
/* Table created to retrieve CSV info from DFP (À supprimer) */
CREATE TABLE utcstudent (
surname TEXT NOT NULL,
firstname TEXT NOT NULL,
speciality TEXT NOT NULL,
level TEXT NOT NULL
);
COMMIT; COMMIT;
...@@ -32,8 +32,9 @@ FROM api LEFT JOIN vapi_subcount ON id=subcountid LEFT JOIN vapi_valcount ON id= ...@@ -32,8 +32,9 @@ FROM api LEFT JOIN vapi_subcount ON id=subcountid LEFT JOIN vapi_valcount ON id=
ORDER BY year, week, code; ORDER BY year, week, code;
CREATE OR REPLACE VIEW vlocaluser AS CREATE OR REPLACE VIEW vlocaluser AS
SELECT * SELECT l.*, s.level
FROM localuser; FROM localuser l
LEFT JOIN student s ON l.utclogin=s.utclogin;
CREATE OR REPLACE VIEW vsubscription AS CREATE OR REPLACE VIEW vsubscription AS
SELECT SELECT
...@@ -48,7 +49,7 @@ LEFT JOIN vlocaluser lo ON su.utclogin=lo.utclogin ...@@ -48,7 +49,7 @@ LEFT JOIN vlocaluser lo ON su.utclogin=lo.utclogin
ORDER BY ap.year, ap.week, ap.code, su.validation, lo.firstname, lo.surname, lo.utclogin; ORDER BY ap.year, ap.week, ap.code, su.validation, lo.firstname, lo.surname, lo.utclogin;
CREATE OR REPLACE VIEW vsubscription_anonymous AS CREATE OR REPLACE VIEW vsubscription_anonymous AS
SELECT normcode, name, normdbegin, normdend, size, speciality, level SELECT normcode, name, normdbegin, normdend, size, level
FROM vsubscription; FROM vsubscription;
COMMIT; COMMIT;
...@@ -7,6 +7,8 @@ psql -c "CREATE DATABASE apisub WITH OWNER apisub" ...@@ -7,6 +7,8 @@ psql -c "CREATE DATABASE apisub WITH OWNER apisub"
psql -d apisub -f "$SQL/apisub_functions.sql" psql -d apisub -f "$SQL/apisub_functions.sql"
psql -d apisub -f "$SQL/apisub_admin.sql" psql -d apisub -f "$SQL/apisub_admin.sql"
psql -d apisub -f "$SQL/apisub_tables.sql" psql -d apisub -f "$SQL/apisub_tables.sql"
psql -d apisub -f "$SQL/apisub_data.sql"
psql -d apisub -c "\copy student (utclogin, level) FROM '$SQL/../data/students.csv' WITH CSV DELIMITER ','"
psql -d apisub -f "$SQL/apisub_views.sql" psql -d apisub -f "$SQL/apisub_views.sql"
psql -d apisub -f "$SQL/apisub_dataset.sql" psql -d apisub -f "$SQL/apisub_dataset.sql"
psql -d apisub -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO apisub" psql -d apisub -c "GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO apisub"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment