Monkey patch a WebOOB bug: No long waiting for the flats to be fetched!

When passing a `Query` to a WebOOB backend and the query has no cities
for this backend, WebOOB was returning nonsense. This is now solved as
we only call the relevant backends for each query.
This commit is contained in:
Lucas Verney 2018-07-25 09:20:48 +02:00
parent cc9ed3d34b
commit 826989f77c

View File

@ -185,10 +185,20 @@ class WebOOBProxy(object):
:return: The matching housing posts, dumped as a list of JSON objects. :return: The matching housing posts, dumped as a list of JSON objects.
""" """
housings = [] housings = []
# List the useful backends for this specific query
useful_backends = [x.backend for x in query.cities]
# TODO: Handle max_entries better # TODO: Handle max_entries better
try: try:
for housing in itertools.islice( for housing in itertools.islice(
self.webnip.do('search_housings', query), self.webnip.do(
'search_housings',
query,
# Only run the call on the required backends.
# Otherwise, WebOOB is doing weird stuff and returning
# nonsense.
backends=[x for x in self.backends
if x.name in useful_backends]
),
max_entries max_entries
): ):
if not store_personal_data: if not store_personal_data: