diff --git a/server/lib/python/cartodb_services/cartodb_services/metrics/user.py b/server/lib/python/cartodb_services/cartodb_services/metrics/user.py index 82aaf95..a5f64b6 100644 --- a/server/lib/python/cartodb_services/cartodb_services/metrics/user.py +++ b/server/lib/python/cartodb_services/cartodb_services/metrics/user.py @@ -118,12 +118,9 @@ class UserMetricsService: for date in self.__generate_date_range(date_from, date_to): redis_prefix = self.__parse_redis_prefix(key_prefix, entity_name, service, metric, date) - score = self._redis_connection.zscore(redis_prefix, date.day) - aggregated_metric += int(score) if score else 0 zero_padded_day = date.strftime(self.DAY_OF_MONTH_ZERO_PADDED) - if str(date.day) != zero_padded_day: - score = self._redis_connection.zscore(redis_prefix, zero_padded_day) - aggregated_metric += int(score) if score else 0 + score = self._redis_connection.zscore(redis_prefix, zero_padded_day) + aggregated_metric += int(score) if score else 0 return aggregated_metric diff --git a/server/lib/python/cartodb_services/test/test_user_service.py b/server/lib/python/cartodb_services/test/test_user_service.py index 201a1de..f1b3598 100644 --- a/server/lib/python/cartodb_services/test/test_user_service.py +++ b/server/lib/python/cartodb_services/test/test_user_service.py @@ -90,19 +90,6 @@ class TestUserService(TestCase): self.redis_conn.zincrby('user:test_user:geocoder_here:success_responses:201506', '01', 400) assert us.used_quota(self.NOKIA_GEOCODER, date(2015, 6,1)) == 400 - @freeze_time("2015-06-01") - def test_should_account_for_wrongly_stored_non_padded_keys(self): - us = self.__build_user_service('test_user') - self.redis_conn.zincrby('user:test_user:geocoder_here:success_responses:201506', '1', 400) - assert us.used_quota(self.NOKIA_GEOCODER, date(2015, 6,1)) == 400 - - @freeze_time("2015-06-01") - def test_should_sum_amounts_from_both_key_formats(self): - us = self.__build_user_service('test_user') - self.redis_conn.zincrby('user:test_user:geocoder_here:success_responses:201506', '1', 400) - self.redis_conn.zincrby('user:test_user:geocoder_here:success_responses:201506', '01', 300) - assert us.used_quota(self.NOKIA_GEOCODER, date(2015, 6,1)) == 700 - @freeze_time("2015-06-15") def test_should_not_request_redis_twice_when_unneeded(self): class MockRedisWithCounter(MockRedis):