From 1ff512839d60114cb645c061d9e259022045ee70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Ignacio=20S=C3=A1nchez=20Lara?= Date: Mon, 23 Jul 2018 13:01:46 +0200 Subject: [PATCH] Fixes empty results count --- .../cartodb_services/geocoder.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/geocoder.py b/server/lib/python/cartodb_services/cartodb_services/geocoder.py index 8d5d456..f23695f 100644 --- a/server/lib/python/cartodb_services/cartodb_services/geocoder.py +++ b/server/lib/python/cartodb_services/cartodb_services/geocoder.py @@ -24,7 +24,7 @@ def compose_address(street, city=None, state=None, country=None): return ', '.join(filter(None, [street, city, state, country])) -def run_street_point_geocoder(plpy, GD, geocoder, service_manager, username, orgname, searches): +def run_street_point_geocoder(plpy, GD, geocoder, service_manager, username, orgname, searches_string): plpy.execute("SELECT cdb_dataservices_server._get_logger_config()") logger_config = GD["logger_config"] @@ -32,9 +32,15 @@ def run_street_point_geocoder(plpy, GD, geocoder, service_manager, username, org success_count, failed_count = 0, 0 + try: + searches = json.loads(searches_string) + except Exception as e: + logger.error('Parsing searches', exception=e, data={'searches': searches_string}) + raise e + try: service_manager.assert_within_limits(quota=False) - geocode_results = geocoder.bulk_geocode(searches=searches) + geocode_results = geocoder.bulk_geocode(searches) results = [] if geocode_results: for result in geocode_results: @@ -94,20 +100,14 @@ class StreetPointBulkGeocoder: SEARCH_KEYS = ['id', 'address', 'city', 'state', 'country'] - def bulk_geocode(self, searches): + def bulk_geocode(self, decoded_searches): """ - :param searches: array of StreetGeocoderSearch + :param decoded_searches: array of StreetGeocoderSearch :return: array of tuples with three elements: * id * latitude and longitude (array of two elements) * empty array (future use: metadata) """ - try: - decoded_searches = json.loads(searches) - except Exception as e: - self._logger.error('General error', exception=e) - raise e - street_geocoder_searches = [] for search in decoded_searches: search_id, address, city, state, country = \