From ad965fffeee50d1785ac8e574dcaf5efd5e906a0 Mon Sep 17 00:00:00 2001 From: Christian Quest Date: Fri, 6 May 2016 16:48:37 +0200 Subject: [PATCH] id/createdate/lastupdate added to properties --- backend.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend.py b/backend.py index 8887a82..7b10eb5 100644 --- a/backend.py +++ b/backend.py @@ -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,))