Script to change username to match full name?

On my site we require the use of actual names and no usernames, I have everything set up so only the full name shows, the only issue I have is when a new user is created their username is set to just their first name and not their full name, which looks messy and confusing when @ mentioning someone. I am using memberful as my sso and I know that’s where the problem really lies. I have contacted them and they refuse to change the behavior due to ‘security concerns’ which is absurd, but I’m stuck with it.

So, I’m looking for a way that I could batch rename all users or just new users to match their full name (with an underscore for spaces of course). Any ideas?

Something along the lines of:

User.last(10).each do |u|
   u.username = UserNameSuggester.suggest(!

Careful when iterating to do stuff in batches of say 1000, you will blow memory if you bring in all your users at once.