Use repository count() methods in place of SQL for statistics
Use message repository in place of SQL in log script