Changes after code review, used orm to calc SLA

It is interesting place. I couldn't find GROUP BY representation in "django" database model. It is why there are places with SQL code. The proposed code change will break scenario when one service is monitored by, for  example, 2 agents and one of them is broken. In such situation, there are 2 entries in service_servicehistory table: first one, from running agent, with response_state=1 and second one, from "failed agent", with response_state=3. From SLA perspective, the service is running and there is no incident, but applying the code change we will decrease SLA. 

It is possible that some agents are broken. So it is real scenario and we must care.
Debug lines from the code.
created 2014-09-17 23:35:09+00:00, response_state 1
created 2014-09-17 23:35:09+00:00, response_state 3

GROUP BY with ORDER BY is critical here. It aggregates entries form service_servicehistory by "created" and takes min for each time period. So, debug lines listed above, will be reduced to only one line:
created 2014-09-17 23:35:09+00:00, response_state 1