Skip to content

Commit

Permalink
feat: add separator to the config and the request
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed Dec 9, 2024
1 parent 01a3926 commit 01fee68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backend/geonature/core/gn_synthese/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand All @@ -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"),
Expand Down
2 changes: 2 additions & 0 deletions backend/geonature/utils/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 01fee68

Please sign in to comment.