X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/9d31a6711605cd4ebea09ca1675e2549b706ba5b..38f467bae3d9a6128180367c0e46ffd0bcad0961:/nominatim/apicmd/status.py diff --git a/nominatim/apicmd/status.py b/nominatim/apicmd/status.py index b5ee9cb9..85071db9 100644 --- a/nominatim/apicmd/status.py +++ b/nominatim/apicmd/status.py @@ -23,10 +23,9 @@ class StatusResult: def __init__(self, status: int, msg: str): self.status = status self.message = msg - # XXX versions really should stay tuples here - self.software_version = version.version_str() + self.software_version = version.NOMINATIM_VERSION self.data_updated: Optional[dt.datetime] = None - self.database_version: Optional[str] = None + self.database_version: Optional[version.NominatimVersion] = None async def _get_database_date(conn: AsyncConnection) -> Optional[dt.datetime]: @@ -41,13 +40,13 @@ async def _get_database_date(conn: AsyncConnection) -> Optional[dt.datetime]: return None -async def _get_database_version(conn: AsyncConnection) -> Optional[str]: +async def _get_database_version(conn: AsyncConnection) -> Optional[version.NominatimVersion]: sql = sqla.text("""SELECT value FROM nominatim_properties WHERE property = 'database_version'""") result = await conn.execute(sql) for row in result: - return cast(str, row[0]) + return version.parse_version(cast(str, row[0])) return None @@ -61,6 +60,6 @@ async def get_status(engine: AsyncEngine) -> StatusResult: status.data_updated = await _get_database_date(conn) status.database_version = await _get_database_version(conn) except asyncpg.PostgresError: - return StatusResult(700, 'No database') + return StatusResult(700, 'Database connection failed') return status