-fixing sql queries for scheduled tasks due to moving to ORM standards