Browse Source

Add an option to ignore stations

master
Gautier P 2 years ago
parent
commit
361725ea4d
  1. 5
      flatisfy/config.py
  2. 14
      flatisfy/filters/__init__.py

5
flatisfy/config.py

@ -99,7 +99,8 @@ DEFAULT_CONFIG = { @@ -99,7 +99,8 @@ DEFAULT_CONFIG = {
"smtp_to": [],
# The web site url, to be used in email notifications. (doesn't matter
# 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__)
@ -169,6 +170,8 @@ def validate_config(config, check_with_data): @@ -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["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
assert config["constraints"]
for constraint in config["constraints"].values():

14
flatisfy/filters/__init__.py

@ -185,8 +185,11 @@ def first_pass(flats_list, constraint, config): @@ -185,8 +185,11 @@ def first_pass(flats_list, constraint, config):
# Guess the postal codes
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
flats_list, ignored_list = refine_with_housing_criteria(flats_list,
constraint)
@ -222,10 +225,11 @@ def second_pass(flats_list, constraint, config): @@ -222,10 +225,11 @@ def second_pass(flats_list, constraint, config):
flats_list = metadata.guess_postal_code(flats_list, constraint, config)
# 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
flats_list = metadata.compute_travel_times(flats_list, constraint, config)
# Compute travel time to specified points
flats_list = metadata.compute_travel_times(flats_list, constraint, config)
# Remove returned housing posts that do not match criteria
flats_list, ignored_list = refine_with_housing_criteria(flats_list,

Loading…
Cancel
Save