Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 819 | Rev 882 | Go to most recent revision | 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 et bdtxa).
*/

--- la requête ---
/*
-- SELECT id_observation, b.num_nom, CONCAT(b.nom_sci, ' ', b.auteur), b.num_taxonomique, b.famille
SELECT id_observation, nom_ret, nom_ret_nn, nt, c.famille
   FROM `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTFX` b
   WHERE (
        nom_sel_nn IS NOT NULL AND nom_sel_nn != 0
        AND 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 SET
       c.nom_ret = CONCAT(b.nom_sci, ' ', b.auteur),
       c.nom_ret_nn = b.num_nom,
       c.nt = b.num_taxonomique,
       c.famille = b.famille
   WHERE (
        nom_sel_nn IS NOT NULL AND nom_sel_nn != 0
        AND nom_referentiel like 'bdtfx%'
        AND nom_sel_nn = num_nom
        AND 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 SET
       c.nom_ret = CONCAT(a.nom_sci, ' ', a.auteur),
       c.nom_ret_nn = a.num_nom,
       c.nt = a.num_tax,
       c.famille = a.famille
   WHERE (
        nom_sel_nn IS NOT NULL AND nom_sel_nn != 0
        AND nom_referentiel like 'bdtxa%'
        AND nom_sel_nn = num_nom
        AND 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`.`isfan_v2013` a SET
       c.nom_ret = CONCAT(a.nom_sci, ' ', a.auteur),
       c.nom_ret_nn = a.num_nom,
       c.nt = a.num_taxonomique,
       c.famille = a.famille
   WHERE (
        nom_sel_nn IS NOT NULL AND nom_sel_nn != 0
        AND nom_referentiel like '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
*/