fetch place info asynchronously

This commit is contained in:
Sarah Hoffmann
2021-04-29 22:16:31 +02:00
parent 602728895e
commit 6ce6f62b8e
3 changed files with 24 additions and 7 deletions

View File

@@ -11,7 +11,7 @@ import psycopg2.extras
class AbstractPlacexRunner:
""" Returns SQL commands for indexing of the placex table.
"""
SELECT_SQL = 'SELECT place_id, (placex_prepare_update(placex)).* FROM placex'
SELECT_SQL = 'SELECT place_id FROM placex'
def __init__(self, rank, analyzer):
self.rank = rank
@@ -28,6 +28,12 @@ class AbstractPlacexRunner:
""".format(','.join(["(%s, %s::hstore, %s::jsonb)"] * num_places))
def get_place_details(self, worker, ids):
worker.perform("""SELECT place_id, (placex_prepare_update(placex)).*
FROM placex WHERE place_id IN %s""",
(tuple((p[0] for p in ids)), ))
def index_places(self, worker, places):
values = []
for place in places: