diff --git a/server/extension/cdb_dataservices_server--0.11.0--0.12.0.sql b/server/extension/cdb_dataservices_server--0.11.0--0.12.0.sql index 5682ba0..d09ba67 100644 --- a/server/extension/cdb_dataservices_server--0.11.0--0.12.0.sql +++ b/server/extension/cdb_dataservices_server--0.11.0--0.12.0.sql @@ -115,4 +115,19 @@ RETURNS SETOF cdb_dataservices_server.isoline AS $$ isolines.append(isoline) return isolines -$$ LANGUAGE plpythonu; \ No newline at end of file +$$ LANGUAGE plpythonu; + + +CREATE OR REPLACE FUNCTION cdb_dataservices_server._get_mapzen_isolines_config(username text, orgname text) +RETURNS boolean AS $$ + cache_key = "user_mapzen_isolines_routing_config_{0}".format(username) + if cache_key in GD: + return False + else: + from cartodb_services.metrics import MapzenIsolinesRoutingConfig + plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) + redis_conn = GD["redis_connection_{0}".format(username)]['redis_metadata_connection'] + mapzen_isolines_config = MapzenIsolinesRoutingConfig(redis_conn, plpy, username, orgname) + GD[cache_key] = mapzen_isolines_config + return True +$$ LANGUAGE plpythonu SECURITY DEFINER; diff --git a/server/extension/cdb_dataservices_server--0.12.0--0.11.0.sql b/server/extension/cdb_dataservices_server--0.12.0--0.11.0.sql index b917b03..1acf9ed 100644 --- a/server/extension/cdb_dataservices_server--0.12.0--0.11.0.sql +++ b/server/extension/cdb_dataservices_server--0.12.0--0.11.0.sql @@ -5,3 +5,4 @@ DROP FUNCTION IF EXISTS cdb_dataservices_server._cdb_mapzen_isolines(text, text, text, geometry(Geometry, 4326), text, integer[], text[]); DROP FUNCTION IF EXISTS cdb_dataservices_server.cdb_mapzen_isodistance(TEXT, TEXT, geometry(Geometry, 4326), TEXT, integer[], text[]); DROP FUNCTION IF EXISTS cdb_dataservices_server.cdb_mapzen_isochrone(TEXT, TEXT, geometry(Geometry, 4326), TEXT, integer[], text[]); +DROP FUNCTION IF EXISTS cdb_dataservices_server._get_mapzen_isolines_config(text, text); \ No newline at end of file