From 67d71fa43ec34edf8143d04f3a00fb64a624c8bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=BCleki=20F=C3=A1bi=C3=A1n?= Date: Fri, 8 May 2020 19:48:31 +0200 Subject: [PATCH] Fixed customers endpoint --- consumer_api/views/consumers_view.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/consumer_api/views/consumers_view.py b/consumer_api/views/consumers_view.py index 0582bc4..ead5288 100644 --- a/consumer_api/views/consumers_view.py +++ b/consumer_api/views/consumers_view.py @@ -8,6 +8,13 @@ from flask_classful import FlaskView class ConsumersView(FlaskView): def get(self): - consumer_list = json.loads((redis_client.get("consumer_list") or b"{}").decode('utf-8')) - current_app.logger.warning(jsonify([v['ip'] for k, v in consumer_list.items()])) - return jsonify([v['ip'] for k, v in consumer_list.items()]) + + keys = redis_client.keys('producer_*') + + list_of_customer_ips = [] + + for key in keys: + info = json.loads((redis_client.get(key) or b"{}").decode('utf-8')) + list_of_customer_ips.append(info['ip']) + + return jsonify(list_of_customer_ips)