diff --git a/wis2box-management/wis2box/metadata/station.py b/wis2box-management/wis2box/metadata/station.py index 8e5103fb6..afcc7d97d 100644 --- a/wis2box-management/wis2box/metadata/station.py +++ b/wis2box-management/wis2box/metadata/station.py @@ -145,25 +145,21 @@ def load_stations(wsi='') -> dict: try: es = Elasticsearch(API_BACKEND_URL) - nbatch = 50 + nbatch = 500 res = es.search(index="stations", query={"match_all": {}}, size=nbatch) # noqa if len(res['hits']['hits']) == 0: LOGGER.debug('No stations found') return stations for hit in res['hits']['hits']: + if wsi != '' and hit['_source']['id'] != wsi: + continue stations[hit['_source']['id']] = hit['_source'] - if wsi != '' and wsi in stations: - return {wsi: stations[wsi]} - if wsi != '': - stations = {} while len(res['hits']['hits']) > 0: res = es.search(index="stations", query={"match_all": {}}, size=nbatch, from_=len(stations)) # noqa for hit in res['hits']['hits']: + if wsi != '' and hit['_source']['id'] != wsi: + continue stations[hit['_source']['id']] = hit['_source'] - if wsi != '' and wsi in stations: - return {wsi: stations[wsi]} - if wsi != '': - stations = {} except Exception as err: LOGGER.error(f'Failed to load stations from backend: {err}')