From 826989f77c4139105ec5346b84a2e195470cf3ca Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Wed, 25 Jul 2018 09:20:48 +0200 Subject: [PATCH] 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. --- flatisfy/fetch.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/flatisfy/fetch.py b/flatisfy/fetch.py index 3a570f5..9867de6 100644 --- a/flatisfy/fetch.py +++ b/flatisfy/fetch.py @@ -185,10 +185,20 @@ class WebOOBProxy(object): :return: The matching housing posts, dumped as a list of JSON objects. """ housings = [] + # List the useful backends for this specific query + useful_backends = [x.backend for x in query.cities] # TODO: Handle max_entries better try: 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 ): if not store_personal_data: