Add an option to ignore stations

This commit is contained in:
Gautier P 2021-01-16 11:19:24 +01:00
parent 76a06cf795
commit 361725ea4d
2 changed files with 13 additions and 6 deletions

View File

@ -99,7 +99,8 @@ DEFAULT_CONFIG = {
"smtp_to": [], "smtp_to": [],
# The web site url, to be used in email notifications. (doesn't matter # The web site url, to be used in email notifications. (doesn't matter
# whether the trailing slash is present or not) # whether the trailing slash is present or not)
"website_url": "http://127.0.0.1:8080" "website_url": "http://127.0.0.1:8080",
"ignore_station": False,
} }
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
@ -169,6 +170,8 @@ def validate_config(config, check_with_data):
assert config["navitia_api_key"] is None or isinstance(config["navitia_api_key"], str) # noqa: E501 assert config["navitia_api_key"] is None or isinstance(config["navitia_api_key"], str) # noqa: E501
assert config["mapbox_api_key"] is None or isinstance(config["mapbox_api_key"], str) # noqa: E501 assert config["mapbox_api_key"] is None or isinstance(config["mapbox_api_key"], str) # noqa: E501
assert config["ignore_station"] is None or isinstance(config["ignore_station"], bool) # noqa: E501
# Ensure constraints are ok # Ensure constraints are ok
assert config["constraints"] assert config["constraints"]
for constraint in config["constraints"].values(): for constraint in config["constraints"].values():

View File

@ -185,8 +185,11 @@ def first_pass(flats_list, constraint, config):
# Guess the postal codes # Guess the postal codes
flats_list = metadata.guess_postal_code(flats_list, constraint, config) flats_list = metadata.guess_postal_code(flats_list, constraint, config)
# Try to match with stations
flats_list = metadata.guess_stations(flats_list, constraint, config) if not config["ignore_station"]:
# Try to match with stations
flats_list = metadata.guess_stations(flats_list, constraint, config)
# Remove returned housing posts that do not match criteria # Remove returned housing posts that do not match criteria
flats_list, ignored_list = refine_with_housing_criteria(flats_list, flats_list, ignored_list = refine_with_housing_criteria(flats_list,
constraint) constraint)
@ -222,10 +225,11 @@ def second_pass(flats_list, constraint, config):
flats_list = metadata.guess_postal_code(flats_list, constraint, config) flats_list = metadata.guess_postal_code(flats_list, constraint, config)
# Better match with stations (confirm and check better) # Better match with stations (confirm and check better)
flats_list = metadata.guess_stations(flats_list, constraint, config) if not config["ignore_station"]:
flats_list = metadata.guess_stations(flats_list, constraint, config)
# Compute travel time to specified points # Compute travel time to specified points
flats_list = metadata.compute_travel_times(flats_list, constraint, config) flats_list = metadata.compute_travel_times(flats_list, constraint, config)
# Remove returned housing posts that do not match criteria # Remove returned housing posts that do not match criteria
flats_list, ignored_list = refine_with_housing_criteria(flats_list, flats_list, ignored_list = refine_with_housing_criteria(flats_list,