Rev 890 | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*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(bdtfx, bdtxa et isfan).Pour éviter un maximum de faux-positifs, nous vérifions aussi que la familleest conservée (même dans certains cas celle-ci a légitimement changé) et quela première partie du nom_sel correspond toujours à la première partie du nouveau nom_sciqui serait attribué.*/--- la requête ---/*-- SELECT id_observation, b.num_nom, CONCAT(b.nom_sci, ' ', b.auteur), b.num_taxonomique, b.familleSELECT id_observation, nom_ret, nom_ret_nn, nt, c.familleFROM `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTFX` bWHERE (nom_sel_nn IS NOT NULLAND nom_referentiel like 'bdtfx%'AND nom_sel_nn = num_nom)ORDER BY id_observation asc;*/--- l'update ---UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTFX` b SETc.nom_ret = CONCAT(b.nom_sci, ' ', b.auteur),c.nom_ret_nn = b.num_nom,c.nt = b.num_taxonomique,c.famille = b.familleWHERE (nom_sel_nn IS NOT NULLAND nom_referentiel = 'bdtfx'AND nom_sel_nn = num_nomAND LOWER(c.famille) = LOWER(b.famille)AND SUBSTRING_INDEX(c.nom_sel, ' ', 1) = SUBSTRING_INDEX(b.nom_sci, ' ', 1));-- 31739 sans les restrictions sur famille et SUBSTRING_INDEX()-- 31524 avec les restrictions sur famille et SUBSTRING_INDEX()UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTXA` a SETc.nom_ret = CONCAT(a.nom_sci, ' ', a.auteur),c.nom_ret_nn = a.num_nom,c.nt = a.num_tax,c.famille = a.familleWHERE (nom_sel_nn IS NOT NULLAND nom_referentiel = 'bdtxa'AND nom_sel_nn = num_nomAND LOWER(c.famille) = LOWER(a.famille)AND SUBSTRING_INDEX(c.nom_sel, ' ', 1) = SUBSTRING_INDEX(a.nom_sci, ' ', 1));-- 49 sans les restrictions sur famille et SUBSTRING_INDEX()-- 47 avec les restrictions sur famille et SUBSTRING_INDEX()UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEISFAN` i SETc.nom_ret = CONCAT(i.nom_sci, ' ', i.auteur),c.nom_ret_nn = i.num_nom,c.nt = i.num_taxonomique,c.famille = i.familleWHERE (nom_sel_nn IS NOT NULLAND nom_referentiel = 'isfan'AND nom_sel_nn = num_nom);/*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*/