id/createdate/lastupdate added to properties

This commit is contained in:
Christian Quest 2016-05-06 16:48:37 +02:00
parent d966e626a3
commit ad965fffee

View file

@ -56,7 +56,7 @@ class EventResource(object):
if id is None:
cur.execute("""
SELECT format('{"type": "FeatureCollection","features": [%s]}',string_agg(feature,',')) FROM
(SELECT '{"type":"Feature", "properties": '|| events_tags::text ||', "geometry":'|| st_asgeojson(st_centroid(geom)) ||' }' as feature
(SELECT '{"type":"Feature", "properties": '|| (events_tags::jsonb || jsonb_build_object('id',events_id,'createdate',createdate,'lastupdate',lastupdate))::text ||', "geometry":'|| st_asgeojson(st_centroid(geom)) ||' }' as feature
FROM events
JOIN geo ON (hash=events_geo)
WHERE events_when @> format('[%s,%s]', now(), now())::tstzrange
@ -66,7 +66,7 @@ SELECT format('{"type": "FeatureCollection","features": [%s]}',string_agg(featur
else:
# get event geojson Feature
cur.execute("""
SELECT format('{"type":"Feature", "properties": '|| events_tags::text ||', "geometry":'|| st_asgeojson(geom)) ||' }'
SELECT format('{"type":"Feature", "properties": '|| (events_tags::jsonb || jsonb_build_object('id',events_id,'createdate',createdate,'lastupdate',lastupdate))::text ||', "geometry":'|| st_asgeojson(geom)) ||' }'
FROM events
JOIN geo ON (hash=events_geo)
WHERE events_id=%s;""", (id,))