1,4 → 1,5 |
/* |
|
Objectif: prendre les observations dont nom_sel_nn est défini |
(et donc dans laquelles les informations générées sont correctes) |
et mettre à jour ces dernières à partir de la dernière version du référentiel |
21,45 → 22,28 |
ORDER BY id_observation asc; |
|
|
Cependant le nom_sel_nn n'est pas directement le num_num du taxon dont le nom est |
Cependant le nom_ret_nn n'est pas directement le num_num du taxon dont le nom est |
retenu. Pour cela, une jointure en bdtfx sur num_nom_retenu est nécessaire et c'est |
ce dernier taxon dont le num_nom est utilisé pour nom_ret_nn. |
Cependant il peut aussi être vide (si aucun nom_retenu "officiel" n'existe). |
|
Attention, les nom_sel_nn = 0 doivent avoir disparus de cel_obs *AU PRÉALABLE* |
Attention, les nom_sel_nn = 0 doivent avoir disparus de cel_obs *AU PRÉALABLE* car le test |
n'est pas effectué. |
cf: maj-cleanup-201307.sql |
*/ |
|
Ici, contrairement à referonosaure_fromNomRet.sql, nous partons du nom_sel en admettant qu'il est |
toujours correct et c'est donc sur ce champ que s'effectue la jointure. |
Quelques exceptions notables existent cependant: |
- certaines observations issues de sauvages sont corrompues, leur nom_sel_nn n'est donc PAS fiable |
- il a été remarqué des observations pour lesquelles le nom_sel_nn était corrompu, impliquant une changement |
de nom de famille incohérent. Pour se prémunir de cela, la famille doit être identique ou presque. |
- enfin, la première partie du nom_sel doit matcher exactement la première partie du nom_sci |
|
|
/* test: |
SELECT c.nom_ret_nn, c.nom_ret, b.nom_sci, b.auteur, c.famille, b.famille, c.nt, b.num_taxonomique |
FROM cel_obs c, tb_eflore.bdtfx_v1_01 b |
WHERE ( |
nom_sel_nn IS NOT NULL AND nom_ret_nn IS NOT NULL AND nom_ret_nn != 0 |
AND nom_referentiel = 'bdtfx' |
AND nom_ret_nn = num_nom |
AND (LOWER(c.famille) = LOWER(b.famille) OR c.famille IS NULL) |
AND (c.famille != b.famille OR c.nom_ret != CONCAT(b.nom_sci, ' ', b.auteur) OR c.nt != b.num_taxonomique) |
); |
= 2 taxons: 75134 et 75468 (changement de nt) |
Consulter referonosaure_fromNomRet.sql pour des informations complémentaires. |
*/ |
|
-- l'update BDTFX avec nom_sel_nn et nom_ret_nn corrects |
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTFX` b SET |
c.nom_ret = CONCAT(b.nom_sci, ' ', b.auteur), |
c.nt = b.num_taxonomique, |
c.famille = b.famille |
WHERE ( |
nom_sel_nn IS NOT NULL AND nom_ret_nn IS NOT NULL AND nom_ret_nn != 0 |
AND nom_referentiel = 'bdtfx' |
AND nom_ret_nn = num_nom |
AND (c.mots_cles_texte IS NULL OR c.mots_cles_texte NOT LIKE '%WidgetFlorileges Sauvages%') -- TODO: bug transferts multiples + mobile.js |
AND (LOWER(c.famille) = LOWER(b.famille) OR c.famille IS NULL) |
); |
-- 25584 |
SELECT ROW_COUNT() AS "BDTFX upd après correction sur nom_ret_nn + nom_sel_nn"; |
|
|
/* test: |
SELECT c.nom_ret_nn, c.nom_ret, bLAST.num_nom, bLAST.nom_sci, bLAST.auteur, c.famille, bLAST.famille, c.nt, bLAST.num_taxonomique |
FROM cel_obs c, tb_eflore.bdtfx_v1_01 b, tb_eflore.bdtfx_v1_01 bLAST |
78,40 → 62,22 |
c.nom_ret_nn = b_nom_ret.num_nom, |
c.nt = b.num_taxonomique, |
c.famille = b.famille, |
c.date_modification = NOW |
c.date_modification = NOW() -- a supprimer pour estimer le nombre de changements réel |
WHERE ( |
b_nom_ret.num_nom = b.num_nom_retenu |
AND nom_sel_nn IS NOT NULL |
AND nom_referentiel = 'bdtfx' |
AND nom_sel_nn = b.num_nom |
AND (c.mots_cles_texte IS NULL OR c.mots_cles_texte NOT LIKE '%WidgetFlorileges Sauvages%') -- TODO: bug transferts multiples + mobile.js |
AND (LOWER(c.famille) = LOWER(b.famille) OR c.famille IS NULL) |
-- TODO: bug transferts multiples + mobile.js |
-- Note: SELECT IF(NULL NOT LIKE "%blah%", 1, 0) : 0 |
AND (c.mots_cles_texte IS NULL OR c.mots_cles_texte NOT LIKE '%WidgetFlorileges Sauvages%') |
AND (LOWER(c.famille) = LOWER(b.famille) OR c.famille IS NULL OR c.famille = 'Famille inconnue') |
AND SUBSTRING_INDEX(c.nom_sel, ' ', 1) = SUBSTRING_INDEX(b.nom_sci, ' ', 1) |
); |
-- 26369 avec indirection num_nom_retenu |
-- 42315 avec indirection num_nom_retenu |
SELECT ROW_COUNT() AS "BDTFX upd après correction sur nom_sel_nn"; |
|
|
|
|
|
|
|
|
-- l'update BDTXA avec nom_sel_nn et nom_ret_nn corrects |
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTXA` a SET |
c.nom_ret = CONCAT(a.nom_sci, ' ', a.auteur), |
c.nt = a.num_tax, |
c.famille = a.famille |
WHERE ( |
nom_sel_nn IS NOT NULL AND nom_ret_nn IS NOT NULL AND nom_ret_nn != 0 |
AND nom_referentiel = 'bdtxa' |
AND nom_ret_nn = num_nom |
AND (LOWER(c.famille) = LOWER(a.famille) OR c.famille IS NULL) |
); |
-- 2 |
SELECT ROW_COUNT() AS "BDTXA upd après correction sur nom_ret_nn + nom_sel_nn"; |
|
-- l'update BDTXA avec nom_sel_nn seul |
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTXA` a, `BASESOURCE`.`TABLEBDTXA` a_nom_ret SET |
c.nom_ret = CONCAT(a_nom_ret.nom_sci, ' ', a_nom_ret.auteur), |
118,7 → 84,7 |
c.nom_ret_nn = a_nom_ret.num_nom, |
c.nt = a.num_tax, |
c.famille = a.famille, |
c.date_modification = NOW |
c.date_modification = NOW() |
WHERE ( |
a_nom_ret.num_nom = a.num_nom_retenu |
AND nom_sel_nn IS NOT NULL |
132,25 → 98,6 |
SELECT ROW_COUNT() AS "BDTXA upd après correction sur nom_sel_nn"; |
|
|
|
|
|
|
|
-- l'update ISFAN avec nom_sel_nn et nom_ret_nn corrects -- |
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEISFAN` i SET |
c.nom_ret = CONCAT(i.nom_sci, ' ', i.auteur), |
c.nt = i.num_taxonomique, |
c.famille = i.famille |
WHERE ( |
nom_sel_nn IS NOT NULL AND nom_ret_nn IS NOT NULL AND nom_ret_nn != 0 |
AND nom_referentiel = 'isfan' |
AND nom_ret_nn = num_nom |
AND (LOWER(c.famille) = LOWER(i.famille) OR c.famille IS NULL) |
); |
-- 2 ou 0 |
SELECT ROW_COUNT() AS "ISFAN upd après correction sur nom_ret_nn + nom_sel_nn"; |
|
-- l'update ISFAN avec nom_sel_nn seul |
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEISFAN` i, `BASESOURCE`.`TABLEISFAN` i_nom_ret SET |
c.nom_ret = CONCAT(i_nom_ret.nom_sci, ' ', i_nom_ret.auteur), |
157,7 → 104,7 |
c.nom_ret_nn = IF(i_nom_ret.num_nom=0,NULL,i_nom_ret.num_nom), |
c.nt = i.num_taxonomique, |
c.famille = i.famille, |
c.date_modification = NOW |
c.date_modification = NOW() |
WHERE ( |
i_nom_ret.num_nom = i.num_nom_retenu |
AND nom_sel_nn IS NOT NULL |
167,24 → 114,3 |
); |
-- 0 |
SELECT ROW_COUNT() AS "ISFAN upd après correction sur nom_sel_nn"; |
|
/* |
Pour observer les différences: |
wdiff -w '$(tput bold;tput setaf 1)' -x '$(tput sgr0)' -y '$(tput bold;tput setaf 2)' -z '$(tput sgr0)' pre.log post.log | \ |
ansi2html.sh --palette=solarized | \ |
sed '/^[0-9]/{/span/!d}' > diff.html |
|
# extract les familles ayant changé: sed '/^[0-9]/{/<\/span>$/!d}' |
# lowercase toutes les familles: awk '{ NF=tolower($NF); print }' |
|
|
# filtre sed: changements de famille "normaux" |
/aceraceae.*sapindaceae/d |
/scrophulariaceae.*plantaginaceae/d |
/globulariaceae.*plantaginaceae/d |
/Famille inconnue.*null/d |
|
# changement "anormaux" |
/rosaceae.*caprifoliaceae/d |
/valerianaceae.*caprifoliaceae/d |
*/ |