diff --git a/NEWS.md b/NEWS.md index 53c6bab..389ed78 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,9 @@ +March 14th, 2018 +================ +* Version `0.17.3` of the python library + * Fix bug with Mapbox routing not using the proper quota value + February 22th, 2018 ================== * Version `0.17.2` of the python library diff --git a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py index 6179d1b..9344af3 100644 --- a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py +++ b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py @@ -153,7 +153,7 @@ class RoutingConfig(ServiceConfig): elif self._routing_provider == self.MAPBOX_PROVIDER: self._mapbox_api_keys = self._db_config.mapbox_routing_api_keys self._mapbox_service_params = self._db_config.mapbox_routing_service_params - self._set_monthly_quota() + self._routing_quota = self._get_effective_monthly_quota(self.QUOTA_KEY) self._set_soft_limit() self._period_end_date = date_parse(self._redis_config[self.PERIOD_END_DATE]) @@ -193,8 +193,8 @@ class RoutingConfig(ServiceConfig): return self._mapbox_service_params @property - def monthly_quota(self): - return self._monthly_quota + def routing_quota(self): + return self._routing_quota @property def period_end_date(self): @@ -204,9 +204,6 @@ class RoutingConfig(ServiceConfig): def soft_limit(self): return self._soft_limit - def _set_monthly_quota(self): - self._monthly_quota = self._get_effective_monthly_quota(self.QUOTA_KEY) - def _set_soft_limit(self): if self.SOFT_LIMIT_KEY in self._redis_config and self._redis_config[self.SOFT_LIMIT_KEY].lower() == 'true': self._soft_limit = True diff --git a/server/lib/python/cartodb_services/cartodb_services/metrics/quota.py b/server/lib/python/cartodb_services/cartodb_services/metrics/quota.py index 7be4c6c..b28462e 100644 --- a/server/lib/python/cartodb_services/cartodb_services/metrics/quota.py +++ b/server/lib/python/cartodb_services/cartodb_services/metrics/quota.py @@ -122,7 +122,7 @@ class QuotaChecker: return False def __check_routing_quota(self): - user_quota = self._user_service_config.monthly_quota + user_quota = self._user_service_config.routing_quota today = date.today() service_type = self._user_service_config.service_type current_used = self._user_service.used_quota(service_type, today) diff --git a/server/lib/python/cartodb_services/setup.py b/server/lib/python/cartodb_services/setup.py index c1c5893..a3c0682 100644 --- a/server/lib/python/cartodb_services/setup.py +++ b/server/lib/python/cartodb_services/setup.py @@ -10,7 +10,7 @@ from setuptools import setup, find_packages setup( name='cartodb_services', - version='0.17.2', + version='0.17.3', description='CartoDB Services API Python Library', diff --git a/server/lib/python/cartodb_services/test/metrics/test_config.py b/server/lib/python/cartodb_services/test/metrics/test_config.py index 89f608e..d233f4b 100644 --- a/server/lib/python/cartodb_services/test/metrics/test_config.py +++ b/server/lib/python/cartodb_services/test/metrics/test_config.py @@ -301,7 +301,7 @@ class TestRoutingConfig(TestCase): self._redis_conn.hset(self._user_key, 'mapzen_routing_quota', 1000) orgname = None config = RoutingConfig(self._redis_conn, self._db_conn, self._username, orgname) - assert config.monthly_quota == 1000 + assert config.routing_quota == 1000 def test_org_quota_overrides_user_quota(self): self._redis_conn.hset(self._user_key, 'mapzen_routing_quota', 1000) @@ -315,7 +315,7 @@ class TestRoutingConfig(TestCase): self._redis_conn.hset(orgname_key, 'here_isolines_quota', 0) config = RoutingConfig(self._redis_conn, self._db_conn, self._username, orgname) - assert config.monthly_quota == 5000 + assert config.routing_quota == 5000 def test_should_have_soft_limit_false_by_default(self): orgname = None diff --git a/server/lib/python/cartodb_services/test/metrics/test_quota.py b/server/lib/python/cartodb_services/test/metrics/test_quota.py index 079c31d..843d90a 100644 --- a/server/lib/python/cartodb_services/test/metrics/test_quota.py +++ b/server/lib/python/cartodb_services/test/metrics/test_quota.py @@ -30,7 +30,7 @@ class TestQuotaChecker(TestCase): username = self.username, organization = None, service_type = self.service_type, - monthly_quota = 1000, + routing_quota = 1000, period_end_date = datetime.today(), soft_limit = False ) @@ -43,7 +43,7 @@ class TestQuotaChecker(TestCase): username = self.username, organization = None, service_type = self.service_type, - monthly_quota = 1000, + routing_quota = 1000, period_end_date = datetime.today(), soft_limit = False ) @@ -61,7 +61,7 @@ class TestQuotaChecker(TestCase): username = self.username, organization = None, service_type = self.service_type, - monthly_quota = 1000, + routing_quota = 1000, period_end_date = datetime.today(), soft_limit = False ) @@ -75,7 +75,7 @@ class TestQuotaChecker(TestCase): username = self.username, organization = None, service_type = self.service_type, - monthly_quota = 1000, + routing_quota = 1000, period_end_date = datetime.today(), soft_limit = True )