Delete blocked user and inactive since XXX

Hi,

I’d like to know the command with gitlab-rails to delete users that meet the two conditions : being blocked and last activity > 360 days.

That will be helpfull for me to mass delete user removed from ldap (and automaticaly blocked) from my gitlab server.

I’ve got something like :

days_inactive = 360
inactive_users = User.active.where(“last_activity_on <= ?”, days_inactive.days.ago)

users.each do |user|
DeleteUserWorker.perform_async(current_user.id, user.id)
end

Is someone could help me to add the status ‘blocked’ parameter?

Thanx by advance!