New file |
0,0 → 1,105 |
/* |
Ceci est une version dérivée de referonosaure.sql dans laquel est postulé que |
les nom_ret sont un critère tangible. |
En effet, sauf bug, il n'y a pas de raison qu'un num_nom_retenu soit moins fiable qu'un num_nom. |
Cependant un taxon peut changer de num_nom_retenu, et auquel cas c'est bien referonosaure.sql |
qu'il faut utiliser. |
Cependant pour un simple "rafraîchissement" des chaînes de caractères attribuées au noms retenus, |
ce script, referonosaure_fromNomRet.sql, doit suffire. |
|
|
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 |
*/ |
|
|
/* 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) |
*/ |
|
-- 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 OR c.famille = 'Famille inconnue') |
); |
-- 25584 |
SELECT ROW_COUNT() AS "BDTFX upd après correction sur nom_ret_nn + 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 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"; |
|
|
|
/* |
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 |
|
|
|
SELECT nom_sel, nom_ret FROM cel_obs GROUP BY nom_sel, nom_ret INTO OUTFILE '/tmp/new.csv' ; |
SELECT id_observation, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn FROM cel_obs INTO OUTFILE '/tmp/id.csv' ; |
$ wdiff x y|sed -n "/\x1b/p"|less |
*/ |