X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/2e9090d121e0eea0a4ff927c380c145389ad2358..474d4230b88033c48ff284d58223cbc632213b85:/nominatim/api/status.py diff --git a/nominatim/api/status.py b/nominatim/api/status.py index b6cd69a8..8ac92f35 100644 --- a/nominatim/api/status.py +++ b/nominatim/api/status.py @@ -7,7 +7,7 @@ """ Classes and function releated to status call. """ -from typing import Optional, cast +from typing import Optional import datetime as dt import dataclasses @@ -36,11 +36,17 @@ async def get_status(conn: SearchConnection) -> StatusResult: sql = sa.select(conn.t.import_status.c.lastimportdate).limit(1) status.data_updated = await conn.scalar(sql) + if status.data_updated is not None: + if status.data_updated.tzinfo is None: + status.data_updated = status.data_updated.replace(tzinfo=dt.timezone.utc) + else: + status.data_updated = status.data_updated.astimezone(dt.timezone.utc) + # Database version - sql = sa.select(conn.t.properties.c.value)\ - .where(conn.t.properties.c.property == 'database_version') - verstr = await conn.scalar(sql) - if verstr is not None: - status.database_version = version.parse_version(cast(str, verstr)) + try: + verstr = await conn.get_property('database_version') + status.database_version = version.parse_version(verstr) + except ValueError: + pass return status