Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/sensibility dashboard #3401

Merged
merged 5 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions backend/geonature/core/gn_synthese/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,14 @@ class VSyntheseForWebApp(DB.Model):
nom_vern = DB.Column(DB.Unicode)
lb_nom = DB.Column(DB.Unicode)
meta_v_taxref = DB.Column(DB.Unicode)
id_statut = DB.Column(DB.Unicode)
id_rang = DB.Column(DB.Unicode)
regne = DB.Column(DB.Unicode)
phylum = DB.Column(DB.Unicode)
classe = DB.Column(DB.Unicode)
ordre = DB.Column(DB.Unicode)
famille = DB.Column(DB.Unicode)
sous_famille = DB.Column(DB.Unicode)
group1_inpn = DB.Column(DB.Unicode)
group2_inpn = DB.Column(DB.Unicode)
group3_inpn = DB.Column(DB.Unicode)
Expand Down
2 changes: 1 addition & 1 deletion backend/geonature/core/gn_synthese/utils/blurring.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def build_blurred_precise_geom_queries(
]
# size hierarchy is the size of the joined blurring area
if select_size_hierarchy:
columns.append(BibAreasTypes.size_hierarchy.label("size_hierarchy"))
columns.append(BibAreasTypesAlias.size_hierarchy.label("size_hierarchy"))
blurred_geom_query = SyntheseQuery(
Synthese,
sa.select(*columns)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
"""Add taxonomie info to v_synthese_for_web_app

Revision ID: d73f74e7b662
Revises: 9f4db1786c22
Create Date: 2025-02-12 17:08:12.043627

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "d73f74e7b662"
down_revision = "9f4db1786c22"
branch_labels = None
depends_on = None


def upgrade():
op.execute(
"""
DROP VIEW gn_synthese.v_synthese_for_web_app;
"""
)

op.execute(
"""
CREATE VIEW gn_synthese.v_synthese_for_web_app AS
SELECT s.id_synthese,
s.unique_id_sinp,
s.unique_id_sinp_grp,
s.id_source,
s.entity_source_pk_value,
s.count_min,
s.count_max,
s.nom_cite,
s.meta_v_taxref,
s.sample_number_proof,
s.digital_proof,
s.non_digital_proof,
s.altitude_min,
s.altitude_max,
s.depth_min,
s.depth_max,
s.place_name,
s."precision",
s.the_geom_4326,
st_asgeojson(s.the_geom_4326) AS st_asgeojson,
s.date_min,
s.date_max,
s.validator,
s.validation_comment,
s.observers,
s.id_digitiser,
s.determiner,
s.comment_context,
s.comment_description,
s.meta_validation_date,
s.meta_create_date,
s.meta_update_date,
s.last_action,
d.id_dataset,
d.dataset_name,
d.id_acquisition_framework,
s.id_nomenclature_geo_object_nature,
s.id_nomenclature_info_geo_type,
s.id_nomenclature_grp_typ,
s.grp_method,
s.id_nomenclature_obs_technique,
s.id_nomenclature_bio_status,
s.id_nomenclature_bio_condition,
s.id_nomenclature_naturalness,
s.id_nomenclature_exist_proof,
s.id_nomenclature_valid_status,
s.id_nomenclature_diffusion_level,
s.id_nomenclature_life_stage,
s.id_nomenclature_sex,
s.id_nomenclature_obj_count,
s.id_nomenclature_type_count,
s.id_nomenclature_sensitivity,
s.id_nomenclature_observation_status,
s.id_nomenclature_blurring,
s.id_nomenclature_source_status,
s.id_nomenclature_determination_method,
s.id_nomenclature_behaviour,
s.reference_biblio,
sources.name_source,
sources.url_source,
t.cd_nom,
t.cd_ref,
t.nom_valide,
t.lb_nom,
t.nom_vern,
s.id_module,
t.group1_inpn,
t.group2_inpn,
t.group3_inpn,
t.id_statut,
t.id_rang,
t.regne,
t.phylum,
t.classe,
t.ordre,
t.famille,
t.sous_famille
FROM gn_synthese.synthese s
JOIN taxonomie.taxref t ON t.cd_nom = s.cd_nom
JOIN gn_meta.t_datasets d ON d.id_dataset = s.id_dataset
JOIN gn_synthese.t_sources sources ON sources.id_source = s.id_source;
"""
)


def downgrade():
op.execute(
"""
DROP VIEW gn_synthese.v_synthese_for_web_app;
"""
)

op.execute(
"""
CREATE VIEW gn_synthese.v_synthese_for_web_app AS
SELECT s.id_synthese,
s.unique_id_sinp,
s.unique_id_sinp_grp,
s.id_source,
s.entity_source_pk_value,
s.count_min,
s.count_max,
s.nom_cite,
s.meta_v_taxref,
s.sample_number_proof,
s.digital_proof,
s.non_digital_proof,
s.altitude_min,
s.altitude_max,
s.depth_min,
s.depth_max,
s.place_name,
s."precision",
s.the_geom_4326,
st_asgeojson(s.the_geom_4326) AS st_asgeojson,
s.date_min,
s.date_max,
s.validator,
s.validation_comment,
s.observers,
s.id_digitiser,
s.determiner,
s.comment_context,
s.comment_description,
s.meta_validation_date,
s.meta_create_date,
s.meta_update_date,
s.last_action,
d.id_dataset,
d.dataset_name,
d.id_acquisition_framework,
s.id_nomenclature_geo_object_nature,
s.id_nomenclature_info_geo_type,
s.id_nomenclature_grp_typ,
s.grp_method,
s.id_nomenclature_obs_technique,
s.id_nomenclature_bio_status,
s.id_nomenclature_bio_condition,
s.id_nomenclature_naturalness,
s.id_nomenclature_exist_proof,
s.id_nomenclature_valid_status,
s.id_nomenclature_diffusion_level,
s.id_nomenclature_life_stage,
s.id_nomenclature_sex,
s.id_nomenclature_obj_count,
s.id_nomenclature_type_count,
s.id_nomenclature_sensitivity,
s.id_nomenclature_observation_status,
s.id_nomenclature_blurring,
s.id_nomenclature_source_status,
s.id_nomenclature_determination_method,
s.id_nomenclature_behaviour,
s.reference_biblio,
sources.name_source,
sources.url_source,
t.cd_nom,
t.cd_ref,
t.nom_valide,
t.lb_nom,
t.nom_vern,
s.id_module,
t.group1_inpn,
t.group2_inpn,
t.group3_inpn,
FROM gn_synthese.synthese s
JOIN taxonomie.taxref t ON t.cd_nom = s.cd_nom
JOIN gn_meta.t_datasets d ON d.id_dataset = s.id_dataset
JOIN gn_synthese.t_sources sources ON sources.id_source = s.id_source;
"""
)
5 changes: 5 additions & 0 deletions backend/geonature/tests/benchmarks/benchmark_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
},
}

benchmark_synthese_regulation = {
"modif_since_validation": False,
"regulations_protection_status": ["REGL"],
}


def benchmark_synthese_intersection_data_test_commune():
return {
Expand Down
11 changes: 10 additions & 1 deletion backend/geonature/tests/benchmarks/test_benchmark_synthese.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .utils import activate_profiling_sql

from .benchmark_generator import BenchmarkTest, CLater
from geonature.tests.fixtures import users


logging.basicConfig()
Expand Down Expand Up @@ -81,6 +82,14 @@ class TestBenchmarkSynthese:
json=benchmark_synthese_with_tree_taxon,
),
)
test_benchmark_synthese_regulation = BenchmarkTest(
CLIENT_POST,
[CLater(SYNTHESE_GET_OBS_URL)],
dict(
user_profile="admin_user",
json=benchmark_synthese_regulation,
),
)


# EXPORT TESTING
Expand All @@ -105,4 +114,4 @@ class TestBenchmarkSynthese:
),
)

add_bluring_to_benchmark_test_class(TestBenchmarkSynthese)
add_bluring_to_benchmark_test_class(TestBenchmarkSynthese, "user_with_blurring")
5 changes: 4 additions & 1 deletion backend/geonature/tests/benchmarks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from geonature.tests.test_synthese import blur_sensitive_observations
import traceback
from geonature.tests.fixtures import app
from pypnusershub.db.models import User

logging.basicConfig()
logger = logging.getLogger("logger-name")
Expand Down Expand Up @@ -62,7 +63,7 @@ def after_cursor_execute(conn, cursor, statement, parameters, context, executema
event.listen(db.engine, "after_cursor_execute", after_cursor_execute)


def add_bluring_to_benchmark_test_class(benchmark_cls: type):
def add_bluring_to_benchmark_test_class(benchmark_cls: type, different_user: str = None):
"""
Add the blurring enabling fixture to all benchmark tests declared in the given class.

Expand All @@ -86,6 +87,8 @@ def add_bluring_to_benchmark_test_class(benchmark_cls: type):
if "fixtures" in kwargs
else [blur_sensitive_observations]
)
if different_user:
kwargs["user_profile"] = different_user
# Recreate BenchmarkTest object including the blurring enabling fixture
setattr(
benchmark_cls,
Expand Down
Loading