if not self.keep_scenario_db:
self.db_drop_database(self.test_db)
+ def reindex_placex(self, db):
+ """ Run the indexing step until all data in the placex has
+ been processed. Indexing during updates can produce more data
+ to index under some circumstances. That is why indexing may have
+ to be run multiple times.
+ """
+ with db.cursor() as cur:
+ while True:
+ self.run_update_script('index')
+
+ cur.execute("SELECT 'a' FROM placex WHERE indexed_status != 0 LIMIT 1")
+ if cur.rowcount == 0:
+ return
+
def run_setup_script(self, *args, **kwargs):
""" Run the Nominatim setup script with the given arguments.
"""
for row in context.table:
PlaceColumn(context).add_row(row, False).db_insert(cur)
- while True:
- context.nominatim.run_update_script('index')
-
- cur.execute("SELECT 'a' FROM placex WHERE indexed_status != 0 LIMIT 1")
- if cur.rowcount == 0:
- break
-
+ context.nominatim.reindex_placex(context.db)
check_database_integrity(context)
@when("updating postcodes")
where, params = NominatimID(oid).table_select()
cur.execute("DELETE FROM place WHERE " + where, params)
- while True:
- context.nominatim.run_update_script('index')
-
- with context.db.cursor() as cur:
- cur.execute("SELECT 'a' FROM placex WHERE indexed_status != 0 LIMIT 1")
- if cur.rowcount == 0:
- break
+ context.nominatim.reindex_placex(context.db)
################################ THEN ##################################