Commit cd997f1c authored by Cédric Bonhomme's avatar Cédric Bonhomme

The number of items in the result is given.

parent 47cf58b9
......@@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-
import random
import datetime
from flask import jsonify, request
import models
......@@ -23,9 +22,9 @@ def what(epc=None):
"""
result = models.EPCISEvent.objects(data__ObjectEvent__epcList__epc=epc).only("data")
if result.count() == 0:
return jsonify(result="no epcis event")
return jsonify(result="no epcis event", nb_items=result.count())
epcis_events = [epcis_event.data for epcis_event in result]
return jsonify(result="ok", epcis_events=epcis_events)
return jsonify(result="ok", nb_items=result.count(), epcis_events=epcis_events)
@app.route('/where/<string:location>', methods=['GET'])
def where(location=None):
......@@ -34,9 +33,9 @@ def where(location=None):
"""
result = models.EPCISEvent.objects(data__ObjectEvent__bizLocation__id=location).only("data")
if result.count() == 0:
return jsonify(result="no epcis event")
return jsonify(result="no epcis event", nb_items=result.count())
epcis_events = [epcis_event.data for epcis_event in result]
return jsonify(result="ok", epcis_events=epcis_events)
return jsonify(result="ok", nb_items=result.count(), epcis_events=epcis_events)
@app.errorhandler(404)
def not_found(error=None):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment