Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 880 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
752 raphael 1
/*
2
Objectif: prendre les observations dont nom_sel_nn est défini
3
(et donc dans laquelles les informations générées sont correctes)
4
et mettre à jour ces dernières à partir de la dernière version du référentiel
890 raphael 5
(bdtfx, bdtxa et isfan).
6
 
7
Pour éviter un maximum de faux-positifs, nous vérifions aussi que la famille
8
est conservée (même dans certains cas celle-ci a légitimement changé) et que
9
la première partie du nom_sel correspond toujours à la première partie du nouveau nom_sci
10
qui serait attribué.
752 raphael 11
*/
12
 
13
--- la requête ---
14
/*
15
-- SELECT id_observation, b.num_nom, CONCAT(b.nom_sci, ' ', b.auteur), b.num_taxonomique, b.famille
16
SELECT id_observation, nom_ret, nom_ret_nn, nt, c.famille
828 raphael 17
   FROM `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTFX` b
752 raphael 18
   WHERE (
890 raphael 19
        nom_sel_nn IS NOT NULL
752 raphael 20
        AND nom_referentiel like 'bdtfx%'
21
        AND nom_sel_nn = num_nom
22
       )
23
   ORDER BY id_observation asc;
24
*/
25
 
26
--- l'update ---
828 raphael 27
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTFX` b SET
752 raphael 28
       c.nom_ret = CONCAT(b.nom_sci, ' ', b.auteur),
29
       c.nom_ret_nn = b.num_nom,
30
       c.nt = b.num_taxonomique,
31
       c.famille = b.famille
32
   WHERE (
890 raphael 33
        nom_sel_nn IS NOT NULL
34
        AND nom_referentiel = 'bdtfx'
752 raphael 35
        AND nom_sel_nn = num_nom
760 raphael 36
        AND LOWER(c.famille) = LOWER(b.famille)
37
        AND SUBSTRING_INDEX(c.nom_sel, ' ', 1) = SUBSTRING_INDEX(b.nom_sci, ' ', 1)
752 raphael 38
       );
760 raphael 39
-- 31739 sans les restrictions sur famille et SUBSTRING_INDEX()
40
-- 31524 avec les restrictions sur famille et SUBSTRING_INDEX()
754 raphael 41
 
760 raphael 42
 
828 raphael 43
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTXA` a SET
754 raphael 44
       c.nom_ret = CONCAT(a.nom_sci, ' ', a.auteur),
45
       c.nom_ret_nn = a.num_nom,
46
       c.nt = a.num_tax,
47
       c.famille = a.famille
48
   WHERE (
890 raphael 49
        nom_sel_nn IS NOT NULL
50
        AND nom_referentiel = 'bdtxa'
754 raphael 51
        AND nom_sel_nn = num_nom
760 raphael 52
        AND LOWER(c.famille) = LOWER(a.famille)
53
        AND SUBSTRING_INDEX(c.nom_sel, ' ', 1) = SUBSTRING_INDEX(a.nom_sci, ' ', 1)
754 raphael 54
       );
760 raphael 55
-- 49 sans les restrictions sur famille et SUBSTRING_INDEX()
56
-- 47 avec les restrictions sur famille et SUBSTRING_INDEX()
57
 
890 raphael 58
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEISFAN` i SET
59
       c.nom_ret = CONCAT(i.nom_sci, ' ', i.auteur),
60
       c.nom_ret_nn = i.num_nom,
61
       c.nt = i.num_taxonomique,
62
       c.famille = i.famille
760 raphael 63
   WHERE (
890 raphael 64
        nom_sel_nn IS NOT NULL
65
        AND nom_referentiel = 'isfan'
760 raphael 66
        AND nom_sel_nn = num_nom
67
       );
68
 
69
 
70
/*
71
Pour observer les différences:
72
wdiff -w '$(tput bold;tput setaf 1)' -x '$(tput sgr0)' -y '$(tput bold;tput setaf 2)' -z '$(tput sgr0)'  pre.log post.log | \
73
      ansi2html.sh --palette=solarized | \
74
      sed '/^[0-9]/{/span/!d}' > diff.html
75
 
76
# extract les familles ayant changé: sed '/^[0-9]/{/<\/span>$/!d}'
77
# lowercase toutes les familles: awk '{ NF=tolower($NF); print }'
78
 
79
 
80
# filtre sed: changements de famille "normaux"
81
/aceraceae.*sapindaceae/d
82
/scrophulariaceae.*plantaginaceae/d
83
/globulariaceae.*plantaginaceae/d
84
/Famille inconnue.*null/d
85
 
86
# changement "anormaux"
87
/rosaceae.*caprifoliaceae/d
88
/valerianaceae.*caprifoliaceae/d
89
*/