Browse Source

Simplify bad/good term match

master
Gautier P 2 years ago
parent
commit
da6cb83f93
  1. 2
      flatisfy/cmds.py
  2. 38
      flatisfy/filters/__init__.py

2
flatisfy/cmds.py

@ -253,4 +253,4 @@ def serve(config): @@ -253,4 +253,4 @@ def serve(config):
server = web_app.QuietWSGIRefServer
print("Launching web viewer running on http://%s:%s" % (config["host"], config["port"]))
app.run(host=config["host"], port=config["port"], server=server)
app.run(host=config["host"], port=config["port"], server=server)

38
flatisfy/filters/__init__.py

@ -117,28 +117,22 @@ def refine_with_details_criteria(flats_list, constraint): @@ -117,28 +117,22 @@ def refine_with_details_criteria(flats_list, constraint):
)
is_ok[i] = False
has_all_good_terms_in_description = True
if constraint["description_should_contain"]:
has_all_good_terms_in_description = all(
term in flat['text']
for term in constraint["description_should_contain"]
)
has_a_bad_term_in_description = False
if constraint["description_should_not_contain"]:
has_a_bad_term_in_description = any(
term in flat['text']
for term in constraint["description_should_not_contain"]
)
if (not has_all_good_terms_in_description
or has_a_bad_term_in_description):
LOGGER.info(
("Description for flat %s does not contain all the required "
"terms, or contains a blacklisted term."),
flat["id"]
)
is_ok[i] = False
for term in constraint["description_should_contain"]:
if term.lower() not in flat['text'].lower():
LOGGER.info(
("Description for flat %s does not contain required term '%s'."),
flat["id"],
term
)
is_ok[i] = False
for term in constraint["description_should_not_contain"]:
if term.lower() in flat['text'].lower():
LOGGER.info(
("Description for flat %s contains blacklisted term '%s'."),
flat["id"],
term
)
is_ok[i] = False
return (
[

Loading…
Cancel
Save