Added a query and endpoint to return the count of complaints for a date-range.

Unit tests for complaints_rest.get_complaint_count have yet to be written.
Maybe there is a better name for the new endpoint.
This commit is contained in:
Rebecca Law
2018-06-07 16:01:41 +01:00
committed by Katie Smith
parent e638653f11
commit 28beeebbf4
4 changed files with 51 additions and 11 deletions

View File

@@ -21,11 +21,12 @@ def get_all_complaints():
return jsonify([x.serialize() for x in complaints]), 200
@complaint_blueprint.route('/total-per-day', methods=['GET'])
@complaint_blueprint.route('/count-by-date-range', methods=['GET'])
def get_complaint_count():
request_json = request.args.to_dict
start_date = None
end_date = None
# TODO: unit tests have yet to be written, need to test setting start and end date
if request_json:
validate(request_json, complaint_count_request)
start_date = request_json.get('start_date', None)