Skip to content

Commit

Permalink
Merge pull request #454 from PnX-SI/fix/observations-meshes
Browse files Browse the repository at this point in the history
Fix repositories/observationsMailles: cast year to integer before use with jsonify
  • Loading branch information
TheoLechemia committed May 22, 2024
2 parents 440e06e + 4a0ef93 commit 372cb76
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 @@ -136,14 +136,17 @@ def lastObservationsCommuneMaille(connection, obs_limit, insee_code):
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 372cb76

Please sign in to comment.