Changes after code review, used orm to calc SLA

Ok will check the code. 

calculatesla is executed once a day, for example, at 3 am. It should have low priority and form that perspective it doesn't matter how long it takes.