Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 754 | Rev 756 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 754 Rev 755
Line 6... Line 6...
6
UPDATE cel_obs SET latitude = NULL, longitude = NULL WHERE longitude = 0 and latitude = 0;
6
UPDATE cel_obs SET latitude = NULL, longitude = NULL WHERE longitude = 0 and latitude = 0;
Line 7... Line 7...
7
 
7
 
8
-- referentiels: 65800 NULL, 13000 ''
8
-- referentiels: 65800 NULL, 13000 ''
9
UPDATE cel_obs SET nom_referentiel = SUBSTRING_INDEX(nom_referentiel, ':', 1);
9
UPDATE cel_obs SET nom_referentiel = SUBSTRING_INDEX(nom_referentiel, ':', 1);
10
UPDATE cel_obs SET nom_referentiel = 'bdtfx' WHERE nom_referentiel IN ('bdtfx_v1','bdnff');
10
UPDATE cel_obs SET nom_referentiel = 'bdtfx' WHERE nom_referentiel IN ('bdtfx_v1','bdnff');
11
-- UPDATE cel_obs SET nom_referentiel = NULL where nom_referentiel = '';
-
 
12
 
-
 
13
 
-
 
14
/*
-
 
15
Cleanup des observation ayant un nom_ret_nn à 0 (mais un nom_ret défini...):
-
 
16
En effet, on peut pour l'instant POSTer $nom_ret, d'où bien souvent nom_sel == nom_ret, cependant nom_ret_nn = 0
-
 
17
(pas d'autodétection).
-
 
18
Nous pourrions donc les nullifier sans remord, ... mais ...
-
 
19
nom_ret == 0 est VALIDE (car bdtfx.num_nom_retenu == 0 est valide) [ 3800 nom_retenu "orphelins" de taxon ]
-
 
20
 
-
 
21
1) créer un index pour les jointures:
-
 
22
CREATE INDEX i_nom_ret ON bdtfx_v1_02 (`nom_sci`(8))
-
 
23
2) regarder les num_nom_ret orphelins de taxon en BDTFX:
-
 
24
SELECT * FROM bdtfx_v1_02 WHERE num_nom_retenu = 0; # 3960
-
 
25
3) regarder les num_nom_ret orphelins de taxon en BDTFX:
-
 
26
SELECT * FROM bdtxa_v1_00 WHERE num_nom_retenu = 0; # 0
-
 
27
4) regarder les orphelins équivalents dans cel_obs:
-
 
28
SELECT date_observation, SUBSTRING(nom_sel, 1, 50), nom_ret_nn, nom_ret, b.nom_sci FROM cel_obs c LEFT JOIN tb_eflore.bdtfx_v1_02 b on (c.nom_ret = b.nom_sci) WHERE nom_ret_nn = 0; # 7740
-
 
29
 
-
 
30
Donc ceux dont le nom_ret à été POSTé manuellement et qui matchent le nom_sci de BDTFX : on les conserve.
-
 
31
Mais les autres, qui ont un nom_ret probablement erroné et un nom_ret_nn à 0, on NULLify les données censées être (correctement) autogénérées !
-
 
32
 
-
 
33
Cela concerne:
-
 
34
SELECT date_observation, SUBSTRING(nom_sel, 1, 50), nom_ret_nn, nom_ret, b.nom_sci FROM cel_obs c LEFT JOIN tb_eflore.bdtfx_v1_02 b on (c.nom_ret = b.nom_sci) WHERE nom_ret_nn = 0 
-
 
35
 AND c.nom_ret != '' AND id_observation NOT IN ( SELECT id_observation FROM cel_obs c, tb_eflore.bdtfx_v1_02 b WHERE c.nom_ret = b.nom_sci AND c.nom_ret_nn = 0 );  # 960
-
 
36
*/
-
 
37
-- D'où la requête : 
-
 
38
UPDATE cel_obs SET nom_sel_nn = NULL, nom_ret = NULL, nom_ret_nn = NULL, nt = NULL, famille = NULL WHERE id_observation IN
-
 
39
( SELECT id_observation FROM cel_obs c LEFT JOIN tb_eflore.bdtfx_v1_02 b on (c.nom_ret = b.nom_sci) WHERE nom_ret_nn = 0 
-
 
40
 AND c.nom_ret != '' AND id_observation NOT IN ( SELECT id_observation FROM cel_obs c, tb_eflore.bdtfx_v1_02 b WHERE c.nom_ret = b.nom_sci AND c.nom_ret_nn = 0 ) );
-
 
41
 
-
 
42
-- TODO
-
 
43
-- UPDATE cel_obs SET nom_ret_nn = NULL WHERE nom_ret_nn = 0;
-
 
44
-- UPDATE cel_obs SET nom_sel_nn = NULL WHERE nom_sel_nn = 0;
-
 
45
 
-
 
46
/*
-
 
47
UPDATE cel_obs SET nom_sel = NULL, nom_sel_nn = NULL, nom_ret = NULL, nom_ret_nn = NULL, nt = NULL, famille = NULL,
-
 
48
	FROM cel_obs 
-
 
49
	WHERE (nom_sel = '' OR nom_sel IS NULL) AND
-
 
50
	(
-
 
51
	(nom_ret IS NOT NULL AND nom_ret != '') OR
-
 
52
	(nom_ret_nn IS NOT NULL AND nom_ret_nn != 0 AND nom_ret_nn != '') OR
-
 
53
	(nt IS NOT NULL AND nt != 0 AND nt != '') OR
-
 
54
	(famille IS NOT NULL AND famille != '')
-
 
55
	)
-
 
56
*/
-