From 01fee68c1991888bd8edd91c0e281718a1e92699 Mon Sep 17 00:00:00 2001 From: Etienne Delclaux Date: Fri, 25 Oct 2024 18:00:10 +0200 Subject: [PATCH] feat: add separator to the config and the request --- backend/geonature/core/gn_synthese/routes.py | 10 ++++++---- backend/geonature/utils/config_schema.py | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/geonature/core/gn_synthese/routes.py b/backend/geonature/core/gn_synthese/routes.py index ede1054752..31a58e3e72 100644 --- a/backend/geonature/core/gn_synthese/routes.py +++ b/backend/geonature/core/gn_synthese/routes.py @@ -1035,6 +1035,9 @@ def taxon_observers(scope, cd_ref): page = request.args.get("page", 1, int) sort_by = request.args.get("sort_by", "observer") sort_order = request.args.get("sort_order", SortOrder.ASC, SortOrder) + field_separator = request.args.get( + "field_separator", app.config["SYNTHESE"]["FIELD_OBSERVERS_SEPARATOR"] + ) # Handle sorting if sort_by not in ["observer", "date_min", "date_max", "observation_count", "media_count"]: @@ -1044,10 +1047,9 @@ def taxon_observers(scope, cd_ref): query = ( db.session.query( - # func.concat(User.prenom_role, " ", User.nom_role).label("observer"), - func.trim(func.unnest(func.string_to_array(Synthese.observers, ","))).label( - "observer" - ), + func.trim( + func.unnest(func.string_to_array(Synthese.observers, field_separator)) + ).label("observer"), func.min(Synthese.date_min).label("date_min"), func.max(Synthese.date_max).label("date_max"), func.count(Synthese.id_synthese).label("observation_count"), diff --git a/backend/geonature/utils/config_schema.py b/backend/geonature/utils/config_schema.py index f5734fbf23..d48b107ead 100644 --- a/backend/geonature/utils/config_schema.py +++ b/backend/geonature/utils/config_schema.py @@ -437,6 +437,8 @@ class Synthese(Schema): # SYNTHESE - TAXON_SHEET TAXON_SHEET = fields.Nested(TaxonSheet, load_default=TaxonSheet().load({})) + FIELD_OBSERVERS_SEPARATOR = fields.String(load_default=",") + @pre_load def warn_deprecated(self, data, **kwargs): deprecated = {