Skip to content

Commit

Permalink
fix: use CorObserverSynthese to list observer
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed Oct 2, 2024
1 parent fb14823 commit b21e079
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions backend/geonature/core/gn_synthese/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from geonature.core.gn_synthese.models import (
BibReportsTypes,
CorAreaSynthese,
CorObserverSynthese,
DefaultsNomenclaturesValue,
Synthese,
TSources,
Expand All @@ -51,6 +52,9 @@
TReport,
SyntheseLogEntry,
)

from pypnusershub.db import User

from geonature.core.gn_synthese.synthese_config import MANDATORY_COLUMNS
from geonature.core.gn_synthese.utils.species_sheet import SpeciesSheetUtils

Expand Down Expand Up @@ -1027,16 +1031,18 @@ def species_observers(scope, cd_ref):
page = request.args.get("page", 1, int)

Check warning on line 1031 in backend/geonature/core/gn_synthese/routes.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/gn_synthese/routes.py#L1030-L1031

Added lines #L1030 - L1031 were not covered by tests

taxref_cd_nom_list = SpeciesSheetUtils.get_cd_nom_list_from_cd_ref(cd_ref)

Check warning on line 1033 in backend/geonature/core/gn_synthese/routes.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/gn_synthese/routes.py#L1033

Added line #L1033 was not covered by tests

query = (

Check warning on line 1035 in backend/geonature/core/gn_synthese/routes.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/gn_synthese/routes.py#L1035

Added line #L1035 was not covered by tests
db.session.query(
func.trim(func.unnest(func.string_to_array(Synthese.observers, ","))).label(
"observer"
),
User.id_role,
func.concat(User.prenom_role, ' ', User.nom_role).label('observer'),
func.min(Synthese.date_min).label("date_min"),
func.max(Synthese.date_max).label("date_max"),
func.count(Synthese.observers).label("count"),
)
.group_by("observer")
.group_by(User.id_role)
.join(CorObserverSynthese, CorObserverSynthese.id_synthese == Synthese.id_synthese)
.join(User, User.id_role == CorObserverSynthese.id_role)
.where(Synthese.cd_nom.in_(taxref_cd_nom_list))
)
query = SpeciesSheetUtils.get_synthese_query_with_scope(g.current_user, scope, query)

Check warning on line 1048 in backend/geonature/core/gn_synthese/routes.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/gn_synthese/routes.py#L1048

Added line #L1048 was not covered by tests
Expand Down

0 comments on commit b21e079

Please sign in to comment.