fix active admin SQL query