From: Stéphane Jacob Date: Sun, 12 Dec 2010 17:42:29 +0000 (+0100) Subject: Fixes education inclusion. X-Git-Tag: xorg/1.0.2~79 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=1dd218522cea6ae08998b0ca107c8fec608ddce8;p=platal.git Fixes education inclusion. Signed-off-by: Stéphane Jacob --- diff --git a/modules/fusionax/Formations.sql b/modules/fusionax/Formations.sql index c1c2222..a966bfb 100644 --- a/modules/fusionax/Formations.sql +++ b/modules/fusionax/Formations.sql @@ -5,8 +5,8 @@ DROP TABLE IF EXISTS `fusionax_formations`; CREATE TABLE IF NOT EXISTS `fusionax_formations` ( FO CHAR(2) NOT NULL COMMENT 'Vaut toujours FO pour cette table', ax_id VARCHAR(8) NOT NULL COMMENT 'Id unique de l''ancien', - Intitule_diplome VARCHAR(255) NOT NULL DEFAULT 0 COMMENT 'Intitulé du diplôme', Intitule_formation VARCHAR(255) NOT NULL DEFAULT 0 COMMENT 'Intitulé de la formation', + Intitule_diplome VARCHAR(255) NOT NULL DEFAULT 0 COMMENT 'Intitulé du diplôme', Descr_formation VARCHAR(255) NOT NULL COMMENT 'Description de la formation', pid INT(11) UNSIGNED DEFAULT NULL, eduid INT(4) DEFAULT NULL, @@ -23,9 +23,9 @@ CREATE TABLE IF NOT EXISTS `fusionax_formations` ( ) ENGINE=InnoDB, CHARSET=utf8; LOAD DATA LOCAL INFILE '{?}Formations.txt' INTO TABLE fusionax_formations CHARACTER SET utf8 FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' -(FO, ax_id, Intitule_diplome, Intitule_formation, Descr_formation); +(FO, ax_id, Intitule_formation, Intitule_diplome, Descr_formation); UPDATE fusionax_formations AS f -INNER JOIN profile_education_enum AS e ON (f.Intitule_diplome = e.abbreviation) - SET f.Intitule_diplome = e.name - WHERE f.Intitule_diplome != ''; +INNER JOIN profile_education_enum AS e ON (f.Intitule_formation = e.abbreviation) + SET f.Intitule_formation = e.name + WHERE f.Intitule_formation != ''; diff --git a/upgrade/1.0.1/merge.php b/upgrade/1.0.1/merge.php index 6d0f1e9..109f8b9 100755 --- a/upgrade/1.0.1/merge.php +++ b/upgrade/1.0.1/merge.php @@ -266,11 +266,15 @@ echo "Starts educations inclusions.\n"; XDB::rawExecute("DELETE FROM fusionax_formations WHERE Intitule_formation = '' AND Intitule_diplome = '' AND Descr_formation = ''"); // Insert ids into fusionax_formations to prevent many joins. +XDB::rawExecute('ALTER TABLE profile_education_enum ADD INDEX (name(60))'); +XDB::rawExecute('ALTER TABLE profile_education_degree_enum ADD INDEX (abbreviation(60))'); XDB::rawExecute('UPDATE fusionax_formations AS f LEFT JOIN profile_education_enum AS pe ON (pe.name = f.Intitule_formation) LEFT JOIN profile_education_degree_enum AS pd ON (pd.abbreviation = f.Intitule_diplome) LEFT JOIN profile_education_field_enum AS pf ON (pf.field = f.Descr_formation) SET f.eduid = pe.id, f.degreeid = pd.id, f.fieldid = pf.id'); +XDB::rawExecute('ALTER TABLE profile_education_enum DROP INDEX name'); +XDB::rawExecute('ALTER TABLE profile_education_degree_enum DROP INDEX abbreviation'); // Updates non complete educations. XDB::rawExecute("UPDATE profile_education AS e INNER JOIN fusionax_formations AS f ON (f.pid = e.pid) @@ -305,8 +309,11 @@ while ($continue > 0) { FROM fusionax_formations"); XDB::rawExecute("DELETE f FROM fusionax_formations AS f - INNER JOIN profile_education AS pe ON (pe.pid = f.pid AND pe.id = $id AND pe.eduid = f.eduid AND pe.degreeid = f.degreeid - AND pe.fieldid = f.fieldid AND pe.program = f.Descr_formation)"); + INNER JOIN profile_education AS pe ON (pe.pid = f.pid AND pe.id = $id) + WHERE (pe.eduid = f.eduid OR (pe.eduid IS NULL AND f.eduid IS NULL)) + AND (pe.degreeid = f.degreeid OR (pe.degreeid IS NULL AND f.degreeid IS NULL)) + AND (pe.fieldid = f.fieldid OR (pe.fieldid IS NULL AND f.fieldid IS NULL)) + AND (pe.program = f.Descr_formation OR (pe.program IS NULL AND f.Descr_formation IS NULL))"); $continue = XDB::affectedRows(); ++$id; }