When we get complaints we'd like to know how many we get in a day or other date range, so if there is a spike in complaints we can act on it.

Add new endpoint to return the number of complaints in a date range.

Unit tests to follow in the next commit.
This commit is contained in:
Rebecca Law
2018-06-07 10:30:50 +01:00
committed by Katie Smith
parent 639a3f42b2
commit e638653f11
3 changed files with 40 additions and 1 deletions

View File

@@ -10,3 +10,7 @@ def save_complaint(complaint):
def fetch_complaints_by_service(service_id):
return Complaint.query.filter_by(service_id=service_id).all()
def fetch_count_of_complaints(start_date, end_date):
return Complaint.count.filter(Complaint.created_at >= start_date, Complaint.created_at < end_date)