Administration » Historique » Version 14
Ludovic Lestrat, 26/04/2018 12:34
1 | 12 | Ludovic Lestrat | [[Mode équipe]] |
---|---|---|---|
2 | 1 | Ludovic Lestrat | |
3 | 12 | Ludovic Lestrat | [[Ajustement de l'outil "Filtre sur emprise"]] |
4 | 8 | Ludovic Lestrat | |
5 | 12 | Ludovic Lestrat | [[Optimisation Observateurs et structure]] |
6 | 10 | Ludovic Lestrat | |
7 | Pour améliorer le temps de filtrage dans l'interface de SICEN Web sur les observateurs et les structures, voici les modifications à apporter. |
||
8 | |||
9 | h2. En base : |
||
10 | |||
11 | <pre> |
||
12 | ALTER TABLE saisie.saisie_observation ADD COLUMN observateurs_pour_tri text; |
||
13 | ALTER TABLE saisie.saisie_observation ADD COLUMN structures_pour_tri text; |
||
14 | ALTER TABLE saisie.suivi_saisie_observation ADD COLUMN observateurs_pour_tri text; |
||
15 | ALTER TABLE saisie.suivi_saisie_observation ADD COLUMN structures_pour_tri text; |
||
16 | |||
17 | CREATE INDEX observateurs_pour_tri_index |
||
18 | ON saisie.saisie_observation |
||
19 | USING gist |
||
20 | (observateurs_pour_tri COLLATE pg_catalog."default" gist_trgm_ops); |
||
21 | |||
22 | CREATE INDEX structures_pour_tri_index |
||
23 | ON saisie.saisie_observation |
||
24 | USING gist |
||
25 | (structures_pour_tri COLLATE pg_catalog."default" gist_trgm_ops); |
||
26 | |||
27 | CREATE OR REPLACE FUNCTION saisie.alimente_observateurs_pour_tri() |
||
28 | RETURNS trigger AS |
||
29 | $BODY$ |
||
30 | BEGIN |
||
31 | NEW.observateurs_pour_tri = md.liste_nom_auteur(NEW.observateur); |
||
32 | RETURN NEW; |
||
33 | END; |
||
34 | $BODY$ |
||
35 | LANGUAGE plpgsql VOLATILE |
||
36 | COST 100; |
||
37 | |||
38 | CREATE TRIGGER alim_observateurs_pour_tri |
||
39 | BEFORE INSERT OR UPDATE OF observateur |
||
40 | ON saisie.saisie_observation |
||
41 | FOR EACH ROW |
||
42 | EXECUTE PROCEDURE saisie.alimente_observateurs_pour_tri(); |
||
43 | |||
44 | CREATE OR REPLACE FUNCTION saisie.alimente_structures_pour_tri() |
||
45 | RETURNS trigger AS |
||
46 | $BODY$ |
||
47 | BEGIN |
||
48 | NEW.structures_pour_tri = md.liste_nom_structure(NEW.structure); |
||
49 | RETURN NEW; |
||
50 | END; |
||
51 | $BODY$ |
||
52 | LANGUAGE plpgsql VOLATILE |
||
53 | COST 100; |
||
54 | |||
55 | CREATE TRIGGER alim_structures_pour_tri |
||
56 | BEFORE INSERT OR UPDATE OF structure |
||
57 | ON saisie.saisie_observation |
||
58 | FOR EACH ROW |
||
59 | EXECUTE PROCEDURE saisie.alimente_structures_pour_tri(); |
||
60 | |||
61 | UPDATE saisie.saisie_observation SET structures_pour_tri = md.liste_nom_structure(structure), observateurs_pour_tri = md.liste_nom_auteur(observateur); |
||
62 | </pre> |
||
63 | |||
64 | |||
65 | h2. Dans l'appli : |
||
66 | |||
67 | h3. Dans Modeles/Adaptations/fGrille.php : |
||
68 | <pre> |
||
69 | [[// $where = str_replace(' observat ', ' md.liste_nom_auteur(observateur) ', $where); |
||
70 | $where = str_replace(' observat ', ' observateurs_pour_tri ', $where); |
||
71 | // $where = str_replace(' struct ', ' md.liste_nom_structure(structure) ', $where); |
||
72 | $where = str_replace(' struct ', ' stuctures_pour_tri ', $where);]] |
||
73 | </pre> |
||
74 | |||
75 | h3. Dans Modeles/GeoJson/gjObs.php : |
||
76 | |||
77 | - remplacer les appels à md.liste_nom_structure(structure) par structures_pour_tri |
||
78 | - remplacer les appels à md.liste_nom_auteur(observateur) par observateurs_pour_tri |
||
79 | 11 | Ludovic Lestrat | |
80 | 12 | Ludovic Lestrat | [[Gestion des tri ET des filtres dans l'interface]] |
81 | 11 | Ludovic Lestrat | |
82 | Afin que les tris restent opérationnels dans le tableau de l'interface, même si un filtre est présent sur un champ, il faut effectuer la modification suivante dans le fichier Sources/Modeles/GeoJson/gjObs.php : |
||
83 | <pre> |
||
84 | if ($limit !== 'AUCUNE') { |
||
85 | $row_number = $start + 1 +$limit; |
||
86 | $req .= 'WHERE row_number > ' . $start . ' AND row_number < ' . $row_number; |
||
87 | $req .= 'order by ' . $sort . ' ' . $dir . ' NULLS LAST;'; // ligne à ajouter |
||
88 | Cf : https://github.com/mathieubossaert/obs_occ/blob/4dfbf9a56b97d9243ad2263d60dda838c8fdbab6/Sources/Modeles/GeoJson/gjObs.php#L45 |
||
89 | </pre> |