Add index to event store call

This commit is contained in:
David Eder 2021-06-11 19:58:58 +02:00
parent b0efd9d35c
commit 99d7ac6a2d

View File

@ -12,18 +12,12 @@ ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
EVENT_STORE_URL = 'http://eventstore:5001/api/keys/' EVENT_STORE_URL = 'http://eventstore:5001/api/keys/'
@app.route('/')
def hello_world():
return 'Hello World'
@app.route('/api/v1/resources/car_events', methods=['GET']) @app.route('/api/v1/resources/car_events', methods=['GET'])
def get_cars_events(): def get_cars_events():
vin = request.args.get('vin') vin = request.args.get('vin')
try: try:
response = requests.get(EVENT_STORE_URL + 'DAF:' + vin + '/') response = requests.get(EVENT_STORE_URL + 'DAF:' + vin + '/0/')
cars = json.loads(response.text) cars = json.loads(response.text)
except requests.exceptions.ConnectionError as e: except requests.exceptions.ConnectionError as e:
@ -32,9 +26,9 @@ def get_cars_events():
return json_util.dumps({'cursor': cars}) return json_util.dumps({'cursor': cars})
@app.route('/api/v1/resources/cars', methods=['GET']) @app.route('/api/v1/resources/cars', methods=['GET'])
def get_cars(): def get_cars():
try: try:
response = requests.get(ENTITY_IDENT_URL + 'cars') response = requests.get(ENTITY_IDENT_URL + 'cars')
cars = response.json()['cursor'] cars = response.json()['cursor']
@ -48,7 +42,6 @@ def get_cars():
@app.route('/api/v1/resources/traffic_lights', methods=['GET']) @app.route('/api/v1/resources/traffic_lights', methods=['GET'])
def get_traffic_lights(): def get_traffic_lights():
try: try:
response = requests.get(ENTITY_IDENT_URL + 'traffic_lights') response = requests.get(ENTITY_IDENT_URL + 'traffic_lights')
traffic_lights = response.json()['cursor'] traffic_lights = response.json()['cursor']