Commit 36b15429 authored by Stephane Crozat's avatar Stephane Crozat

Adding SQL tables and views to manage user information (name, surname,...

Adding SQL tables and views to manage user information (name, surname, speciality and level), joining with DFP file
parent 7a1cbc6f
......@@ -28,12 +28,32 @@ CREATE TABLE subscribe (
PRIMARY KEY (utclogin,api)
);
/* Table created to collect CAS user surname and firstname */
CREATE TABLE localuser (
utclogin TEXT PRIMARY KEY,
surname TEXT,
firstname TEXT
);
/* Table created to retrieve CSV info from DFP */
CREATE TABLE utcstudent (
surname TEXT NOT NULL,
firstname TEXT NOT NULL,
speciality TEXT NOT NULL,
level TEXT NOT NULL
);
/*
\COPY utcstudent (firstname,surname,speciality,level) FROM '/home/stc/inscriptions_A18.csv' WITH CSV HEADER DELIMITER ';' QUOTE '"'
*/
CREATE VIEW vlocaluser AS
SELECT l.utclogin, u.surname, u.firstname, MAX(u.speciality) AS speciality, MAX(u.level) AS level,
CASE WHEN COUNT(*)>1 THEN 'duplication' END AS warning
FROM localuser l
LEFT JOIN utcstudent u ON l.surname=u.surname AND l.firstname=u.firstname
GROUP BY l.utclogin, u.surname, u.firstname;
/** Test dataset
INSERT INTO api VALUES (
1,'Poésie et ingénierie',2019,'H',TO_DATE('20190121','yyyymmdd'),TO_DATE('20190125','yyyymmdd'),24,2,'stc@utc.fr'
......@@ -59,6 +79,8 @@ GROUP BY ap.code, normcode, ap.name, ap.year, ap.semester, dbegin, dend, ap.size
ORDER BY ap.year, ap.semester, ap.dbegin, ap.dend, ap.code;
CREATE OR REPLACE VIEW vsubscription AS
SELECT ap.*, TO_CHAR(su.subdate,'DD/MM/YYYY') AS subdate, su.utclogin
FROM subscribe su JOIN vApi ap ON ap.code=su.api
ORDER BY ap.year, ap.semester, ap.dbegin, ap.dend, ap.code, su.utclogin;
SELECT ap.*, TO_CHAR(su.subdate,'DD/MM/YYYY') AS subdate, su.utclogin, lo.firstname, lo.surname, lo.speciality, lo.level
FROM subscribe su
JOIN vapi ap ON ap.code=su.api
LEFT JOIN vlocaluser lo ON su.utclogin=lo.utclogin
ORDER BY ap.year, ap.semester, ap.dbegin, ap.dend, ap.code, lo.firstname, lo.surname, su.utclogin;
......@@ -2,8 +2,8 @@
Dans Scenari, depuis `catalogue.website`, exporter une archive (clic droit)
mv catalogue*.scar catalogue.zip
rm -rf catxml
mv catalogue*.scar catalogue.zip &&
rm -rf catxml &&
unzip catalogue.zip -d catxml
Ouvrir le fichier `catalogue.website` avec Oxygen ajouter le ligne
......@@ -13,9 +13,11 @@ Générer et récupérer le SQL
# Génération CSV depuis la base Postgres
\COPY (SELECT * FROM vApi) TO 'api.csv' CSV HEADER DELIMITER ';' QUOTE '"'
\COPY (SELECT DISTINCT mail FROM vApi) TO 'api_ml.txt'
\COPY (SELECT * FROM vapi) TO '/home/stc/api.csv' CSV HEADER DELIMITER ';' QUOTE '"'
\COPY (SELECT * FROM vsubscription) TO '/home/stc/api_sub.csv' CSV HEADER DELIMITER ';' QUOTE '"'
\COPY (SELECT DISTINCT mail FROM vapi) TO '/home/stc/api_ml.txt'
scp stc@pic.crzt.fr:/home/stc/api*.* .
......@@ -23,16 +25,12 @@ scp stc@pic.crzt.fr:/home/stc/api*.* .
Générer et télécharger depuis Scenari
rm -rf apihtml
unzip api_gen_simpleSite.zip -d apihtml
rm -rf apihtml &&
unzip api_gen_simpleSite.zip -d apihtml &&
rsync -va apihtml/* wapint@stargate.utc.fr:/volgen/user1x/users/wapint/public_html/
# MAJ catalogue sur le serveur web
rm -rf cathtml
unzip catalogue_gen_site.zip -d cathtml
rm -rf cathtml &&
unzip catalogue_gen_site.zip -d cathtml &&
rsync -va cathtml/* wapint@stargate.utc.fr:/volgen/user1x/users/wapint/public_html/cat/
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