Administration » Historique » Version 13
Ludovic Lestrat, 26/04/2018 12:33
| 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 | 9 | Ludovic Lestrat | Pour éviter une montée en charge du CPU lié à l'utilisation de cet outil, il faut modifier deux fichiers comme indiqué sur les pages github : |
| 6 | 8 | Ludovic Lestrat | - Environnement/Outils/FiltreCarte.php : https://github.com/mathieubossaert/obs_occ/commit/6a1a7afc30cb01f97d7de5a1e5811b665c32c2ab |
| 7 | - Sources/Configuration/ConfigUtilisee.php : https://github.com/mathieubossaert/obs_occ/commit/a029fb9206edc9e430c1a0466987e55087bf3347#diff-7be1b306267c9f2d4fc3deb5a0b2c3dc |
||
| 8 | 10 | Ludovic Lestrat | |
| 9 | 12 | Ludovic Lestrat | [[Optimisation Observateurs et structure]] |
| 10 | 10 | Ludovic Lestrat | |
| 11 | Pour améliorer le temps de filtrage dans l'interface de SICEN Web sur les observateurs et les structures, voici les modifications à apporter. |
||
| 12 | |||
| 13 | h2. En base : |
||
| 14 | |||
| 15 | <pre> |
||
| 16 | ALTER TABLE saisie.saisie_observation ADD COLUMN observateurs_pour_tri text; |
||
| 17 | ALTER TABLE saisie.saisie_observation ADD COLUMN structures_pour_tri text; |
||
| 18 | ALTER TABLE saisie.suivi_saisie_observation ADD COLUMN observateurs_pour_tri text; |
||
| 19 | ALTER TABLE saisie.suivi_saisie_observation ADD COLUMN structures_pour_tri text; |
||
| 20 | |||
| 21 | CREATE INDEX observateurs_pour_tri_index |
||
| 22 | ON saisie.saisie_observation |
||
| 23 | USING gist |
||
| 24 | (observateurs_pour_tri COLLATE pg_catalog."default" gist_trgm_ops); |
||
| 25 | |||
| 26 | CREATE INDEX structures_pour_tri_index |
||
| 27 | ON saisie.saisie_observation |
||
| 28 | USING gist |
||
| 29 | (structures_pour_tri COLLATE pg_catalog."default" gist_trgm_ops); |
||
| 30 | |||
| 31 | CREATE OR REPLACE FUNCTION saisie.alimente_observateurs_pour_tri() |
||
| 32 | RETURNS trigger AS |
||
| 33 | $BODY$ |
||
| 34 | BEGIN |
||
| 35 | NEW.observateurs_pour_tri = md.liste_nom_auteur(NEW.observateur); |
||
| 36 | RETURN NEW; |
||
| 37 | END; |
||
| 38 | $BODY$ |
||
| 39 | LANGUAGE plpgsql VOLATILE |
||
| 40 | COST 100; |
||
| 41 | |||
| 42 | CREATE TRIGGER alim_observateurs_pour_tri |
||
| 43 | BEFORE INSERT OR UPDATE OF observateur |
||
| 44 | ON saisie.saisie_observation |
||
| 45 | FOR EACH ROW |
||
| 46 | EXECUTE PROCEDURE saisie.alimente_observateurs_pour_tri(); |
||
| 47 | |||
| 48 | CREATE OR REPLACE FUNCTION saisie.alimente_structures_pour_tri() |
||
| 49 | RETURNS trigger AS |
||
| 50 | $BODY$ |
||
| 51 | BEGIN |
||
| 52 | NEW.structures_pour_tri = md.liste_nom_structure(NEW.structure); |
||
| 53 | RETURN NEW; |
||
| 54 | END; |
||
| 55 | $BODY$ |
||
| 56 | LANGUAGE plpgsql VOLATILE |
||
| 57 | COST 100; |
||
| 58 | |||
| 59 | CREATE TRIGGER alim_structures_pour_tri |
||
| 60 | BEFORE INSERT OR UPDATE OF structure |
||
| 61 | ON saisie.saisie_observation |
||
| 62 | FOR EACH ROW |
||
| 63 | EXECUTE PROCEDURE saisie.alimente_structures_pour_tri(); |
||
| 64 | |||
| 65 | UPDATE saisie.saisie_observation SET structures_pour_tri = md.liste_nom_structure(structure), observateurs_pour_tri = md.liste_nom_auteur(observateur); |
||
| 66 | </pre> |
||
| 67 | |||
| 68 | |||
| 69 | h2. Dans l'appli : |
||
| 70 | |||
| 71 | h3. Dans Modeles/Adaptations/fGrille.php : |
||
| 72 | <pre> |
||
| 73 | [[// $where = str_replace(' observat ', ' md.liste_nom_auteur(observateur) ', $where); |
||
| 74 | $where = str_replace(' observat ', ' observateurs_pour_tri ', $where); |
||
| 75 | // $where = str_replace(' struct ', ' md.liste_nom_structure(structure) ', $where); |
||
| 76 | $where = str_replace(' struct ', ' stuctures_pour_tri ', $where);]] |
||
| 77 | </pre> |
||
| 78 | |||
| 79 | h3. Dans Modeles/GeoJson/gjObs.php : |
||
| 80 | |||
| 81 | - remplacer les appels à md.liste_nom_structure(structure) par structures_pour_tri |
||
| 82 | - remplacer les appels à md.liste_nom_auteur(observateur) par observateurs_pour_tri |
||
| 83 | 11 | Ludovic Lestrat | |
| 84 | 12 | Ludovic Lestrat | [[Gestion des tri ET des filtres dans l'interface]] |
| 85 | 11 | Ludovic Lestrat | |
| 86 | 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 : |
||
| 87 | <pre> |
||
| 88 | if ($limit !== 'AUCUNE') { |
||
| 89 | $row_number = $start + 1 +$limit; |
||
| 90 | $req .= 'WHERE row_number > ' . $start . ' AND row_number < ' . $row_number; |
||
| 91 | $req .= 'order by ' . $sort . ' ' . $dir . ' NULLS LAST;'; // ligne à ajouter |
||
| 92 | Cf : https://github.com/mathieubossaert/obs_occ/blob/4dfbf9a56b97d9243ad2263d60dda838c8fdbab6/Sources/Modeles/GeoJson/gjObs.php#L45 |
||
| 93 | </pre> |