Removed logger

This commit is contained in:
Mario de Frutos 2015-11-10 16:54:47 +01:00
parent 29ec5da86d
commit f22807553f
3 changed files with 5 additions and 9 deletions

View File

@ -5,9 +5,8 @@ from datetime import date
class QuotaService:
""" Class to manage all the quota operation for the Geocoder SQL API Extension """
def __init__(self, logger, user_id, transaction_id, **kwargs):
self.logger = logger
self._user_service = user_service.UserService(logger, user_id, **kwargs)
def __init__(self, user_id, transaction_id, **kwargs):
self._user_service = user_service.UserService(user_id, **kwargs)
self.transaction_id = transaction_id
def check_user_quota(self):
@ -15,7 +14,6 @@ class QuotaService:
# TODO We need to add the hard/soft limit flag for the geocoder
user_quota = self.user_service.user_quota()
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
def increment_geocoder_use(self, amount=1):

View File

@ -14,9 +14,8 @@ class UserService:
REDIS_DEFAULT_HOST = 'localhost'
REDIS_DEFAULT_PORT = 6379
def __init__(self, logger, user_id, **kwargs):
def __init__(self, user_id, **kwargs):
self.user_id = user_id
self.logger = logger
if self.REDIS_CONNECTION_KEY in kwargs:
self._redis_connection = self.__get_redis_connection(redis_connection=kwargs[self.REDIS_CONNECTION_KEY])
else:
@ -55,7 +54,6 @@ class UserService:
return conn
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'])
conn = redis.Redis(connection_pool=pool)
return conn

View File

@ -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]:
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:
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():
result = plpy.execute("SELECT geom FROM geocode_admin0_polygons(Array[\'{0}\']::text[])".format(search))