Skip to content

Commit

Permalink
Merge pull request #3586 from lonvia/reduce-lookup-calls
Browse files Browse the repository at this point in the history
Reduce number of SQL queries for lookup call
  • Loading branch information
lonvia authored Nov 13, 2024
2 parents ae8694a + 2735ea7 commit 1a64c3b
Show file tree
Hide file tree
Showing 3 changed files with 277 additions and 183 deletions.
5 changes: 2 additions & 3 deletions src/nominatim_api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .sql import sqlite_functions, sqlalchemy_functions # noqa
from .connection import SearchConnection
from .status import get_status, StatusResult
from .lookup import get_detailed_place, get_simple_place
from .lookup import get_places, get_detailed_place
from .reverse import ReverseGeocoder
from .search import ForwardGeocoder, Phrase, PhraseType, make_query_analyzer
from . import types as ntyp
Expand Down Expand Up @@ -222,8 +222,7 @@ async def lookup(self, places: Sequence[ntyp.PlaceRef], **params: Any) -> Search
conn.set_query_timeout(self.query_timeout)
if details.keywords:
await make_query_analyzer(conn)
return SearchResults(filter(None,
[await get_simple_place(conn, p, details) for p in places]))
return await get_places(conn, places, details)

async def reverse(self, coord: ntyp.AnyPoint, **params: Any) -> Optional[ReverseResult]:
""" Find a place by its coordinates. Also known as reverse geocoding.
Expand Down
Loading

0 comments on commit 1a64c3b

Please sign in to comment.