Simplify bad/good term match
This commit is contained in:
parent
caa4961679
commit
da6cb83f93
@ -117,28 +117,22 @@ def refine_with_details_criteria(flats_list, constraint):
|
|||||||
)
|
)
|
||||||
is_ok[i] = False
|
is_ok[i] = False
|
||||||
|
|
||||||
has_all_good_terms_in_description = True
|
for term in constraint["description_should_contain"]:
|
||||||
if constraint["description_should_contain"]:
|
if term.lower() not in flat['text'].lower():
|
||||||
has_all_good_terms_in_description = all(
|
LOGGER.info(
|
||||||
term in flat['text']
|
("Description for flat %s does not contain required term '%s'."),
|
||||||
for term in constraint["description_should_contain"]
|
flat["id"],
|
||||||
)
|
term
|
||||||
|
)
|
||||||
has_a_bad_term_in_description = False
|
is_ok[i] = False
|
||||||
if constraint["description_should_not_contain"]:
|
for term in constraint["description_should_not_contain"]:
|
||||||
has_a_bad_term_in_description = any(
|
if term.lower() in flat['text'].lower():
|
||||||
term in flat['text']
|
LOGGER.info(
|
||||||
for term in constraint["description_should_not_contain"]
|
("Description for flat %s contains blacklisted term '%s'."),
|
||||||
)
|
flat["id"],
|
||||||
|
term
|
||||||
if (not has_all_good_terms_in_description
|
)
|
||||||
or has_a_bad_term_in_description):
|
is_ok[i] = False
|
||||||
LOGGER.info(
|
|
||||||
("Description for flat %s does not contain all the required "
|
|
||||||
"terms, or contains a blacklisted term."),
|
|
||||||
flat["id"]
|
|
||||||
)
|
|
||||||
is_ok[i] = False
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
[
|
[
|
||||||
|
Loading…
Reference in New Issue
Block a user