Make the grab_next_visits sql query modular
This will allow us to easily plug new scheduling policies in that function.