Removed logger
This commit is contained in:
@@ -5,9 +5,8 @@ from datetime import date
|
|||||||
class QuotaService:
|
class QuotaService:
|
||||||
""" Class to manage all the quota operation for the Geocoder SQL API Extension """
|
""" Class to manage all the quota operation for the Geocoder SQL API Extension """
|
||||||
|
|
||||||
def __init__(self, logger, user_id, transaction_id, **kwargs):
|
def __init__(self, user_id, transaction_id, **kwargs):
|
||||||
self.logger = logger
|
self._user_service = user_service.UserService(user_id, **kwargs)
|
||||||
self._user_service = user_service.UserService(logger, user_id, **kwargs)
|
|
||||||
self.transaction_id = transaction_id
|
self.transaction_id = transaction_id
|
||||||
|
|
||||||
def check_user_quota(self):
|
def check_user_quota(self):
|
||||||
@@ -15,7 +14,6 @@ class QuotaService:
|
|||||||
# TODO We need to add the hard/soft limit flag for the geocoder
|
# TODO We need to add the hard/soft limit flag for the geocoder
|
||||||
user_quota = self.user_service.user_quota()
|
user_quota = self.user_service.user_quota()
|
||||||
current_used = self.user_service.used_quota_month()
|
current_used = self.user_service.used_quota_month()
|
||||||
self.logger.debug("User quota: {0} --- Current used quota: {1}".format(user_quota, current_used))
|
|
||||||
return True if (current_used + 1) < user_quota else False
|
return True if (current_used + 1) < user_quota else False
|
||||||
|
|
||||||
def increment_geocoder_use(self, amount=1):
|
def increment_geocoder_use(self, amount=1):
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ class UserService:
|
|||||||
REDIS_DEFAULT_HOST = 'localhost'
|
REDIS_DEFAULT_HOST = 'localhost'
|
||||||
REDIS_DEFAULT_PORT = 6379
|
REDIS_DEFAULT_PORT = 6379
|
||||||
|
|
||||||
def __init__(self, logger, user_id, **kwargs):
|
def __init__(self, user_id, **kwargs):
|
||||||
self.user_id = user_id
|
self.user_id = user_id
|
||||||
self.logger = logger
|
|
||||||
if self.REDIS_CONNECTION_KEY in kwargs:
|
if self.REDIS_CONNECTION_KEY in kwargs:
|
||||||
self._redis_connection = self.__get_redis_connection(redis_connection=kwargs[self.REDIS_CONNECTION_KEY])
|
self._redis_connection = self.__get_redis_connection(redis_connection=kwargs[self.REDIS_CONNECTION_KEY])
|
||||||
else:
|
else:
|
||||||
@@ -55,7 +54,6 @@ class UserService:
|
|||||||
return conn
|
return conn
|
||||||
|
|
||||||
def __create_redis_connection(self, redis_config):
|
def __create_redis_connection(self, redis_config):
|
||||||
self.logger.debug("Connecting to redis...")
|
|
||||||
pool = redis.ConnectionPool(host=redis_config['host'], port=redis_config['port'], db=redis_config['db'])
|
pool = redis.ConnectionPool(host=redis_config['host'], port=redis_config['port'], db=redis_config['db'])
|
||||||
conn = redis.Redis(connection_pool=pool)
|
conn = redis.Redis(connection_pool=pool)
|
||||||
return conn
|
return conn
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ $$
|
|||||||
|
|
||||||
if user_id in SD and tx_id in SD[user_id] and 'redis_connection' in SD[user_id][tx_id]:
|
if user_id in SD and tx_id in SD[user_id] and 'redis_connection' in SD[user_id][tx_id]:
|
||||||
logging.debug("Using redis cached connection...")
|
logging.debug("Using redis cached connection...")
|
||||||
qs = quota_service.QuotaService(logging, user_id, tx_id, redis_connection=SD[user_id][tx_id]['redis_connection'])
|
qs = quota_service.QuotaService(user_id, tx_id, redis_connection=SD[user_id][tx_id]['redis_connection'])
|
||||||
else:
|
else:
|
||||||
qs = quota_service.QuotaService(logging, user_id, tx_id, redis_host='localhost', redis_port=6379, redis_db=5)
|
qs = quota_service.QuotaService(user_id, tx_id, redis_host='localhost', redis_port=6379, redis_db=5)
|
||||||
|
|
||||||
if qs.check_user_quota():
|
if qs.check_user_quota():
|
||||||
result = plpy.execute("SELECT geom FROM geocode_admin0_polygons(Array[\'{0}\']::text[])".format(search))
|
result = plpy.execute("SELECT geom FROM geocode_admin0_polygons(Array[\'{0}\']::text[])".format(search))
|
||||||
|
|||||||
Reference in New Issue
Block a user