Geocoder street function with quota checking

This commit is contained in:
Mario de Frutos
2016-01-20 20:57:24 +01:00
parent b2fa8739e2
commit fc35911b91
7 changed files with 175 additions and 101 deletions
@@ -0,0 +1,16 @@
-- Get the Redis configuration from the _conf table --
CREATE OR REPLACE FUNCTION cdb_geocoder_server._get_geocoder_config(username text, orgname text)
RETURNS boolean AS $$
cache_key = "user_geocoder_config_{0}".format(username)
if cache_key in GD:
return False
else:
from cartodb_geocoder import config_helper
plpy.execute("SELECT cdb_geocoder_server._connect_to_redis('{0}')".format(username))
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metadata_connection']
geocoder_config = config_helper.GeocoderConfig(redis_conn, username, orgname)
# --Think about the security concerns with this kind of global cache, it should be only available
# --for this user session but...
GD[cache_key] = geocoder_config
return True
$$ LANGUAGE plpythonu;