Avoid loading multiple times the same data
There was a bug in `data.py` which made it load the same data as many times as the number of postal codes in constraints. This is now fixed.
This commit is contained in:
parent
d396d33506
commit
b187a106e4
@ -83,8 +83,13 @@ def load_data(model, constraint, config):
|
||||
get_session = database.init_db(config["database"], config["search_index"])
|
||||
results = []
|
||||
with get_session() as session:
|
||||
areas = []
|
||||
# Get areas to fetch from, using postal codes
|
||||
for postal_code in constraint["postal_codes"]:
|
||||
area = data_files.french_postal_codes_to_iso_3166(postal_code)
|
||||
areas.append(data_files.french_postal_codes_to_iso_3166(postal_code))
|
||||
# Load data for each area
|
||||
areas = list(set(areas))
|
||||
for area in areas:
|
||||
results.extend(
|
||||
session.query(model)
|
||||
.filter(model.area == area).all()
|
||||
|
Loading…
Reference in New Issue
Block a user