Rename minimum_photos config option to minimum_nb_photos
This commit is contained in:
parent
5bce6369ec
commit
f81deb9f13
@ -153,6 +153,8 @@ under the `constraints` key. The available constraints are:
|
||||
`null`) from the place identified by the GPS coordinates `LAT` and `LNG`
|
||||
(latitude and longitude), and we call this place `foobar` in human-readable
|
||||
form. Beware that `time` constraints are in **seconds**.
|
||||
* `minimum_nb_photos` let you filter out posts with less than this number of
|
||||
photos.
|
||||
|
||||
|
||||
You can think of constraints as "a set of criterias to filter out flats". You
|
||||
|
@ -34,7 +34,7 @@ DEFAULT_CONFIG = {
|
||||
"cost": (None, None), # (min, max) in currency unit
|
||||
"rooms": (None, None), # (min, max)
|
||||
"bedrooms": (None, None), # (min, max)
|
||||
"minimum_photos": None,
|
||||
"minimum_nb_photos": None, # min number of photos
|
||||
"time_to": {} # Dict mapping names to {"gps": [lat, lng],
|
||||
# "time": (min, max) }
|
||||
# Time is in seconds
|
||||
@ -139,10 +139,10 @@ def validate_config(config, check_with_data):
|
||||
assert isinstance(constraint["type"], str)
|
||||
assert constraint["type"].upper() in ["RENT", "SALE", "SHARING"]
|
||||
|
||||
assert "minimum_photos" in constraint
|
||||
if constraint["minimum_photos"]:
|
||||
assert isinstance(constraint["minimum_photos"], int)
|
||||
assert constraint["minimum_photos"] >= 0
|
||||
assert "minimum_nb_photos" in constraint
|
||||
if constraint["minimum_nb_photos"]:
|
||||
assert isinstance(constraint["minimum_nb_photos"], int)
|
||||
assert constraint["minimum_nb_photos"] >= 0
|
||||
|
||||
assert "house_types" in constraint
|
||||
assert constraint["house_types"]
|
||||
|
@ -80,7 +80,7 @@ def refine_with_housing_criteria(flats_list, constraint):
|
||||
)
|
||||
|
||||
|
||||
def refine_with_minimum_photos(flats_list, constraint):
|
||||
def refine_with_minimum_nb_photos(flats_list, constraint):
|
||||
"""
|
||||
Filter a list of flats according to the minimum number of photos criterion.
|
||||
|
||||
@ -99,7 +99,7 @@ def refine_with_minimum_photos(flats_list, constraint):
|
||||
# Check number of pictures
|
||||
has_enough_photos = tools.is_within_interval(
|
||||
flat.get('photos', []),
|
||||
constraint['minimum_photos'],
|
||||
constraint['minimum_nb_photos'],
|
||||
None
|
||||
)
|
||||
if not has_enough_photos:
|
||||
@ -107,7 +107,7 @@ def refine_with_minimum_photos(flats_list, constraint):
|
||||
"Flat %s only has %d photos, it should have at least %d.",
|
||||
flat["id"],
|
||||
len(flat['photos']),
|
||||
constraint['minimum_photos']
|
||||
constraint['minimum_nb_photos']
|
||||
)
|
||||
is_ok[i] = False
|
||||
|
||||
@ -203,7 +203,7 @@ def second_pass(flats_list, constraint, config):
|
||||
constraint)
|
||||
|
||||
# Remove return housing posts which do not have enough photos
|
||||
flats_list, ignored_list = refine_with_minimum_photos(flats_list,
|
||||
flats_list, ignored_list = refine_with_minimum_nb_photos(flats_list,
|
||||
constraint)
|
||||
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user