Skip to content

Instantly share code, notes, and snippets.

@descovi
Created May 10, 2018 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save descovi/8ed0952372f5f0a408c5e4664821cf62 to your computer and use it in GitHub Desktop.
Save descovi/8ed0952372f5f0a408c5e4664821cf62 to your computer and use it in GitHub Desktop.
Giacomo Counter
businesses = Business.select{ |business| check_data_presence_for(business)}
previous_count = BusinessArea::RegisteredOffice.count
count = businesses.count.to_s
count_digits = count.length
cursors = ['|', '/', '-', '\\', '|', '/', '-', '\\']
businesses.each.with_index(1) do |business, index|
cursor = cursors[index % 32 / 4]
formatted_index = index.to_s.rjust(count_digits, '0')
print "#{cursor} #{formatted_index}/#{count} (business #{business.id}) #{cursor}"
params = extract_params_from(business)
registered_office = BusinessArea::RegisteredOffice.new(params)
registered_office.save(validate: false)
end
current_count = BusinessArea::RegisteredOffice.count - previous_count
# Qui Giacomo faceva qualcosa ma Ale lo ha cancellato.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment