Skip to content

Commit

Permalink
fix(repositories): fix observations meshes web service
Browse files Browse the repository at this point in the history
  • Loading branch information
jpm-cbna committed Dec 7, 2023
1 parent 5a918b1 commit 4a0ef93
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions atlas/modeles/repositories/vmObservationsMaillesRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,17 @@ def lastObservationsCommuneMaille(connection, mylimit, insee):
def getObservationsTaxonCommuneMaille(connection, insee, cd_ref):
sql = """
SELECT
o.cd_ref, t.id_maille, t.geojson_maille,
extract(YEAR FROM o.dateobs) AS annee
FROM atlas.vm_observations o
JOIN atlas.vm_communes c
ON ST_INTERSECTS(o.the_geom_point, c.the_geom)
JOIN atlas.t_mailles_territoire t
ON ST_INTERSECTS(t.the_geom, o.the_geom_point)
WHERE o.cd_ref = :thiscdref AND c.insee = :thisInsee
o.cd_ref,
t.id_maille,
t.geojson_maille,
extract(YEAR FROM o.dateobs)::INT AS annee
FROM atlas.vm_observations AS o
JOIN atlas.vm_communes AS c
ON ST_INTERSECTS(o.the_geom_point, c.the_geom)
JOIN atlas.t_mailles_territoire AS t
ON ST_INTERSECTS(t.the_geom, o.the_geom_point)
WHERE o.cd_ref = :thiscdref
AND c.insee = :thisInsee
ORDER BY id_maille
"""
observations = connection.execute(text(sql), thisInsee=insee, thiscdref=cd_ref)
Expand Down

0 comments on commit 4a0ef93

Please sign in to comment.