Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquesfize committed Feb 28, 2024
2 parents 97ae2d3 + 3a50e9c commit e224936
Show file tree
Hide file tree
Showing 20 changed files with 276 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ config/conf_gn_module.toml
*.egg-info
/dist
venv
.vscode
7 changes: 0 additions & 7 deletions .vscode/settings.json

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
CHANGELOG
=========

1.5.0 (2024-02-28)
------------------

Nécessite la version 2.14.0 (ou plus) de GeoNature.

**🚀 Nouveautés**

* Ajout du Groupe 3 INPN dans les filtres (par @mvergez)
* Compatibilité avec GeoNature 2.14

1.4.0 (2023-08-23)
------------------

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Installation
- Relancez GeoNature
```bash
sudo systemctl restart geonature
sudo systemctl restart geonature-worker
```

Il vous faut désormais attribuer des permissions aux groupes ou utilisateurs que vous souhaitez, pour qu'ils puissent accéder et utiliser le module (voir https://docs.geonature.fr/admin-manual.html#gestion-des-droits). Si besoin une commande permet d'attribuer automatiquement toutes les permissions dans tous les modules à un groupe ou utilisateur administrateur.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0
1.5.0
8 changes: 6 additions & 2 deletions backend/gn_module_dashboard/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def get_synthese_stat():
params = request.args
q = DB.session.query(
label("year", func.date_part("year", VSynthese.date_min)),
func.count(VSynthese.id_synthese),
func.count(distinct(VSynthese.cd_ref)),
func.count(VSynthese.id_synthese).label("count_id_synthese"),
func.count(distinct(VSynthese.cd_ref)).label("count_cd_ref"),
).group_by("year")
if ("selectedRegne" in params) and (params["selectedRegne"] != ""):
q = q.filter(VSynthese.regne == params["selectedRegne"])
Expand All @@ -42,6 +42,8 @@ def get_synthese_stat():
q = q.filter(VSynthese.ordre == params["selectedOrdre"])
if "selectedFamille" in params and (params["selectedFamille"] != ""):
q = q.filter(VSynthese.famille == params["selectedFamille"])
if ("selectedGroup3INPN" in params) and (params["selectedGroup3INPN"] != ""):
q = q.filter(VSynthese.group3_inpn == params["selectedGroup3INPN"])
if ("selectedGroup2INPN" in params) and (params["selectedGroup2INPN"] != ""):
q = q.filter(VSynthese.group2_inpn == params["selectedGroup2INPN"])
if ("selectedGroup1INPN" in params) and (params["selectedGroup1INPN"] != ""):
Expand Down Expand Up @@ -84,6 +86,8 @@ def get_areas_stat(simplify_level, type_code):
x = x + """AND t.group1_inpn = '""" + params["selectedGroup1INPN"] + """' """
if ("selectedGroup2INPN") in params and (params["selectedGroup2INPN"] != ""):
x = x + """AND t.group2_inpn = '""" + params["selectedGroup2INPN"] + """' """
if ("selectedGroup3INPN") in params and (params["selectedGroup3INPN"] != ""):
x = x + """AND t.group3_inpn = '""" + params["selectedGroup3INPN"] + """' """
# q : Requête générale
q = text(
""" WITH count AS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-08-25 14:19:25.865116
"""

from alembic import op
import sqlalchemy as sa
import pkg_resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2022-12-21 09:03:51.048633
"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-02-23 16:48:42.267746
"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
"""group3_inpn_vm_synthese
Revision ID: 9a9ef04f6010
Revises: cef2c2d66eb2
Create Date: 2023-09-06 14:29:46.848022
"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "9a9ef04f6010"
down_revision = "cef2c2d66eb2"
branch_labels = None
depends_on = None


def upgrade():
op.execute("DROP MATERIALIZED VIEW gn_dashboard.vm_taxonomie")
op.execute("DROP MATERIALIZED VIEW gn_dashboard.vm_synthese")
op.execute(
"""
CREATE MATERIALIZED VIEW gn_dashboard.vm_synthese
TABLESPACE pg_default
AS SELECT s.id_synthese,
s.id_source,
s.id_dataset,
s.id_nomenclature_obj_count,
s.count_min,
s.count_max,
s.cd_nom,
t.cd_ref,
s.nom_cite,
t.id_statut,
t.id_rang,
t.regne,
t.phylum,
t.classe,
t.ordre,
t.famille,
t.sous_famille,
t.group1_inpn,
t.group2_inpn,
t.group3_inpn,
t.lb_nom,
t.nom_vern,
t.url,
s.altitude_min,
s.altitude_max,
s.date_min,
s.date_max
FROM gn_synthese.synthese s
JOIN taxonomie.taxref t ON s.cd_nom = t.cd_nom
WITH DATA;
CREATE INDEX vm_synthese_cd_ref_idx ON gn_dashboard.vm_synthese USING btree (cd_ref);
CREATE UNIQUE INDEX vm_synthese_id_synthese_idx ON gn_dashboard.vm_synthese USING btree (id_synthese);
"""
)
op.execute(
"""
CREATE MATERIALIZED VIEW gn_dashboard.vm_taxonomie
TABLESPACE pg_default
AS SELECT 'Règne'::text AS level,
COALESCE(vm_synthese.regne, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.regne
UNION ALL
SELECT 'Phylum'::text AS level,
COALESCE(vm_synthese.phylum, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.phylum
UNION ALL
SELECT 'Classe'::text AS level,
COALESCE(vm_synthese.classe, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.classe
UNION ALL
SELECT 'Ordre'::text AS level,
COALESCE(vm_synthese.ordre, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.ordre
UNION ALL
SELECT 'Famille'::text AS level,
COALESCE(vm_synthese.famille, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.famille
UNION ALL
SELECT 'Groupe INPN 1'::text AS level,
COALESCE(vm_synthese.group1_inpn, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.group1_inpn
UNION ALL
SELECT 'Groupe INPN 2'::text AS level,
COALESCE(vm_synthese.group2_inpn, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.group2_inpn
UNION ALL
SELECT 'Groupe INPN 3'::text AS level,
COALESCE(vm_synthese.group3_inpn, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.group3_inpn
WITH DATA;
CREATE UNIQUE INDEX vm_taxonomie_name_taxon_level_idx ON gn_dashboard.vm_taxonomie USING btree (name_taxon, level);
"""
)


def downgrade():
op.execute("DROP MATERIALIZED VIEW gn_dashboard.vm_taxonomie")
op.execute("DROP MATERIALIZED VIEW gn_dashboard.vm_synthese")
op.execute(
"""
CREATE MATERIALIZED VIEW gn_dashboard.vm_synthese
TABLESPACE pg_default
AS SELECT s.id_synthese,
s.id_source,
s.id_dataset,
s.id_nomenclature_obj_count,
s.count_min,
s.count_max,
s.cd_nom,
t.cd_ref,
s.nom_cite,
t.id_statut,
t.id_rang,
t.regne,
t.phylum,
t.classe,
t.ordre,
t.famille,
t.sous_famille,
t.group1_inpn,
t.group2_inpn,
t.lb_nom,
t.nom_vern,
t.url,
s.altitude_min,
s.altitude_max,
s.date_min,
s.date_max
FROM gn_synthese.synthese s
JOIN taxonomie.taxref t ON s.cd_nom = t.cd_nom
WITH DATA;
CREATE INDEX vm_synthese_cd_ref_idx ON gn_dashboard.vm_synthese USING btree (cd_ref);
CREATE UNIQUE INDEX vm_synthese_id_synthese_idx ON gn_dashboard.vm_synthese USING btree (id_synthese);
"""
)
op.execute(
"""
CREATE MATERIALIZED VIEW gn_dashboard.vm_taxonomie
TABLESPACE pg_default
AS SELECT 'Règne'::text AS level,
COALESCE(vm_synthese.regne, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.regne
UNION ALL
SELECT 'Phylum'::text AS level,
COALESCE(vm_synthese.phylum, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.phylum
UNION ALL
SELECT 'Classe'::text AS level,
COALESCE(vm_synthese.classe, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.classe
UNION ALL
SELECT 'Ordre'::text AS level,
COALESCE(vm_synthese.ordre, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.ordre
UNION ALL
SELECT 'Famille'::text AS level,
COALESCE(vm_synthese.famille, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.famille
UNION ALL
SELECT 'Groupe INPN 1'::text AS level,
COALESCE(vm_synthese.group1_inpn, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.group1_inpn
UNION ALL
SELECT 'Groupe INPN 2'::text AS level,
COALESCE(vm_synthese.group2_inpn, 'Not defined'::character varying) AS name_taxon
FROM gn_dashboard.vm_synthese
GROUP BY vm_synthese.group2_inpn
WITH DATA;
CREATE UNIQUE INDEX vm_taxonomie_name_taxon_level_idx ON gn_dashboard.vm_taxonomie USING btree (name_taxon, level);
"""
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-06-08 16:46:03.951872
"""

from alembic import op
import sqlalchemy as sa

Expand Down
1 change: 1 addition & 0 deletions backend/gn_module_dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class VSynthese(DB.Model):
nom_vern = DB.Column(DB.Unicode)
group1_inpn = DB.Column(DB.Unicode)
group2_inpn = DB.Column(DB.Unicode)
group3_inpn = DB.Column(DB.Unicode)
altitude_min = DB.Column(DB.Integer)
altitude_max = DB.Column(DB.Integer)
lon = DB.Column(DB.Unicode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ export class AnnualReportComponent implements OnInit {
} else {
tempNewSpecies[element.group2_inpn] = 1;
}
if (element.group3_inpn in tempNewSpecies) {
tempNewSpecies[element.group3_inpn] += 1;
} else {
tempNewSpecies[element.group3_inpn] = 1;
}
});
const randomColor = [];
for (let group in tempNewSpecies) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ <h3 class="card-header" style="text-align:center; color:white">
<option> </option>
<option> Groupe INPN 1 </option>
<option> Groupe INPN 2 </option>
<option> Groupe INPN 3 </option>
<option> Règne </option>
<option> Phylum </option>
<option> Classe </option>
Expand Down Expand Up @@ -55,6 +56,17 @@ <h3 class="card-header" style="text-align:center; color:white">
</ng-container>
</select>
</div>
<div class="form-group" id="group3_inpn_filter" *ngIf="filter === 'Groupe INPN 3'">
<label class="col-form-label"> Groupe INPN 3 </label>
<select class="form-control form-control-sm" formControlName="selectedGroup3INPN"
(change)="getCurrentTax($event)" [disableControl]="spinner">
<option> </option>
<ng-container *ngFor="let group3_inpn of taxonomies['Groupe INPN 3']">
<option [ngValue]="group3_inpn" *ngIf="group3_inpn != 'Not defined'">
{{ group3_inpn }} </option>
</ng-container>
</select>
</div>
<div class="form-group" id="regne_filter" *ngIf="filter === 'Règne'">
<label class="col-form-label"> Règne </label>
<select class="form-control form-control-sm" formControlName="selectedRegne"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export class DashboardHistogramComponent implements OnInit {
selectedFamille: fb.control(null),
selectedGroup1INPN: fb.control(null),
selectedGroup2INPN: fb.control(null),
selectedGroup3INPN: fb.control(null),
taxon: fb.control(null),
});
}
Expand All @@ -130,9 +131,9 @@ export class DashboardHistogramComponent implements OnInit {
this.subscription = this.dataService.getDataSynthese().subscribe((data) => {
// Remplissage des array des labels et des données à afficher, paramètres de l'histogramme
data.forEach((elt) => {
this.barChartLabels.push(elt[0]);
this.barChartData[0]['data'].push(elt[1]);
this.barChartData[1]['data'].push(elt[2]);
this.barChartLabels.push(elt["year"]);
this.barChartData[0]['data'].push(elt["count_id_synthese"]);
this.barChartData[1]['data'].push(elt["count_cd_ref"]);
});
this.chart.chart.update();
// Enregistrement des données "sans filtre" pour pouvoir les afficher plus rapidement par la suite
Expand All @@ -148,6 +149,7 @@ export class DashboardHistogramComponent implements OnInit {
// Réinitialiser l'ancien filtre qui a été sélectionné pour empêcher les erreurs de requête
this.histForm.controls['selectedGroup1INPN'].reset();
this.histForm.controls['selectedGroup2INPN'].reset();
this.histForm.controls['selectedGroup3INPN'].reset();
this.histForm.controls['selectedRegne'].reset();
this.histForm.controls['selectedPhylum'].reset();
this.histForm.controls['selectedClasse'].reset();
Expand Down Expand Up @@ -198,10 +200,10 @@ export class DashboardHistogramComponent implements OnInit {
var i = start;
var keepGoing = true;
while (i < dataLength && keepGoing == true) {
if (year == data[i][0]) {
barChartDataTemp[0]['data'].push(data[i][1]);
if (year == data[i]["year"]) {
barChartDataTemp[0]['data'].push(data[i]["count_id_synthese"]);
if (this.filter != 'Rechercher un taxon/une espèce...') {
barChartDataTemp[1]['data'].push(data[i][2]);
barChartDataTemp[1]['data'].push(data[i]["count_cd_ref"]);
}
keepGoing = false;
start = i + 1;
Expand Down
Loading

0 comments on commit e224936

Please sign in to comment.