Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 755 → Rev 756

/trunk/scripts/modules/cel/A_LIRE.txt
20,6 → 20,8
4) maj-referentiel-und-201307.sql
MAJ du référentiel pour les observation n'ayant pas de nom_ret_nn (tentative de détermination par nom)
 
5) referonosaure.sql
MAJ des observations (valides) avec les nouvelles données générées, à partir de bdtfx/bdtxa
 
 
 
33,9 → 35,6
 
 
 
 
 
 
=== 2: À propos de la table cel_references ===
Celle-ci existe car:
* les projets doivent être indépendants (eflore, cel, projets nvjfl, ...)
/trunk/scripts/modules/cel/cel_references.sh
115,3 → 115,5
WHERE b.num_tax IS NULL AND b.num_tax != '';
 
DROP TEMPORARY TABLE IF EXISTS `T_nvjfl_v2007`, `T_nva_v2013_06`, `T_basevegflor`;
 
SELECT count(1), "résultat théorique: 104422" FROM @dst;
/trunk/scripts/modules/cel/maj-referentiel-201307.sql
1,5 → 1,5
/*
Mise à jour de réferentiels NULL ou vides pour les observations avec nom_ret_nn
Mise à jour de réferentiels NULL ou vides pour les observations dotées d'un nom_sel_nn
75427 observations trouvées au 2013/07/19
 
Les observations problématiques sont les suivantes:
6,16 → 6,64
SELECT id_observation, nom_referentiel, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille
FROM cel_obs
WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel != '' AND nom_sel IS NOT NULL AND nom_ret_nn IS NOT NULL;
 
Or maj-cleanup-201307.sql reset les valeurs des observations ayant un nom_sel NULL ou '', de plus la préférence de sélection est
donné au nom_sel (incluant les synonymes) plutôt que nom_ret_nn.
 
La requête est donc:
SELECT id_observation, nom_referentiel, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille
FROM cel_obs WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel_nn IS NOT NULL;
=> 76486
*/
 
 
DROP TEMPORARY TABLE IF EXISTS T_bis;
DROP PROCEDURE IF EXISTS majreferentiel;
 
CREATE TEMPORARY TABLE IF NOT EXISTS T_bis ( INDEX(`nom`(30))) AS \
SELECT "bdtfx" AS valid_ref, CONCAT(b.nom_sci, ' ', b.auteur) AS nom, b.num_nom, b.num_taxonomique, b.famille FROM tb_eflore.bdtfx_v1_02 b UNION ALL \
SELECT "bdtxa" AS valid_ref, CONCAT(a.nom_sci, ' ', a.auteur) AS nom, a.num_nom, a.num_tax, a.famille FROM tb_eflore.bdtxa_v1_00 a;
 
/* Donc nous JOINons:
-- INNER JOIN sur bdtfx: 69719
SELECT id_observation, nom_referentiel, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, c.famille FROM cel_obs c INNER JOIN tb_eflore.bdtfx_v1_02 b ON (b.num_nom = c.nom_sel_nn) WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel_nn IS NOT NULL;
-- INNER JOIN sur bdtxa: 79471 dont 9752 en dup (bdtxa + bdtfx), eg: 1005047
SELECT id_observation, nom_referentiel, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, c.famille FROM cel_obs c INNER JOIN T_bis b ON (b.num_nom = c.nom_sel_nn) WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel_nn IS NOT NULL;
*/
 
/* d'où GROUP BY id_observation HAVING count(id_observation) = 1 */
/*
TODO:
SELECT * FROM cel_obs WHERE nom_ret_nn IS NULL;
CREATE TEMPORARY TABLE T_bis ( INDEX(`nom`)) AS
(SELECT "bdtfx", CONCAT(b.nom_sci, ' ', b.auteur) AS nom, b.num_nom, b.num_taxonomique, b.famille FROM tb_eflore.bdtfx_v1_02 b
UNION ALL
SELECT "bdtxa", CONCAT(a.nom_sci, ' ', a.auteur) AS nom, a.num_nom, a.num_tax, a.famille FROM tb_eflore.bdtxa_v1_00 a);
SELECT id_observation, nom_referentiel, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, c.famille
FROM cel_obs c
INNER JOIN T_bis b
ON (b.num_nom = c.nom_sel_nn)
WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel_nn IS NOT NULL GROUP BY id_observation HAVING count(id_observation) = 1;
-- 59967, tous bdtfx...
*/
 
 
delimiter |
 
DROP TEMPORARY TABLE IF EXISTS T_bis;
CREATE PROCEDURE majreferentiel()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE subst INT DEFAULT 0;
DECLARE _id_observation bigint(20) DEFAULT 0;
DECLARE _valid_ref varchar(20) DEFAULT NULL;
DECLARE cur1 CURSOR FOR SELECT id_observation, valid_ref FROM cel_obs c INNER JOIN T_bis b ON (b.num_nom = c.nom_sel_nn)
WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel_nn IS NOT NULL group by id_observation HAVING count(id_observation) = 1;
-- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
 
OPEN cur1;
REPEAT
FETCH cur1 INTO _id_observation, _valid_ref;
UPDATE tb_cel.cel_obs c SET nom_referentiel = _valid_ref WHERE id_observation = _id_observation;
SET subst = subst + 1;
UNTIL done END REPEAT;
select subst AS 'nombre de mises à jour de référentiel effectuées';
CLOSE cur1;
END
|
 
delimiter ;
/trunk/scripts/modules/cel/maj-cleanup-201307.sql
9,3 → 9,14
UPDATE cel_obs SET nom_referentiel = SUBSTRING_INDEX(nom_referentiel, ':', 1);
UPDATE cel_obs SET nom_referentiel = 'bdtfx' WHERE nom_referentiel IN ('bdtfx_v1','bdnff');
-- TODO: UPDATE cel_obs SET nom_referentiel = NULL where nom_referentiel = '';
 
-- suppression des infos générées pour les observations dont le nom_sel à été supprimé par l'utilisateur
-- 3172
UPDATE tb_cel.cel_obs c SET
c.nom_ret = '',
c.nom_sel_nn = NULL,
c.nom_ret = NULL,
c.nom_ret_nn = NULL,
c.nt = NULL,
c.famille = NULL;
WHERE nom_sel = '' OR nom_sel IS NULL;