Skip to content

Commit 2544fa3

Browse files
krivardmelange396
andauthored
Apply suggestions from code review
Co-authored-by: melange396 <[email protected]>
1 parent c1db533 commit 2544fa3

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/acquisition/covid_hosp/common/database.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ def nan_safe_dtype(dtype, value):
206206
many_values = []
207207
except Exception as e:
208208
if logger:
209-
logger.info('error on insert', index=index, values=values)
210-
logger.error(e)
209+
logger.error('error on insert', publ_date=publication_date, in_lines=(n-5_000, n), index=index, values=values, exception=e)
211210
raise e
212211
# insert final batch
213212
if many_values:

src/acquisition/covid_hosp/common/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ def limited_string(value):
8080
return limited_string
8181

8282
GEOCODE_LENGTH = 32
83-
GEOCODE_PATTERN = re.compile(r'POINT \(([0-9.-]*) ([0-9.-]*)\)')
83+
GEOCODE_PATTERN = re.compile(r'POINT \((-?[0-9.]+) (-?[0-9.]+)\)')
8484
def limited_geocode(value):
8585
if len(value) < Utils.GEOCODE_LENGTH:
8686
return value
87-
# otherwise parse and reduce precision to 5
87+
# otherwise parse and set precision to 6 decimal places
8888
m = Utils.GEOCODE_PATTERN.match(value)
8989
if not m:
9090
raise CovidHospException(f"Couldn't parse geocode '{value}'")
91-
return f'POINT ({" ".join(map(lambda x: f"{float(x):.6f}", m.groups()))})'
91+
return f'POINT ({" ".join(f"{float(x):.6f}" for x in m.groups())})'
9292

9393
def issues_to_fetch(metadata, newer_than, older_than, logger=False):
9494
"""

0 commit comments

Comments
 (0)