Skip to content

Instantly share code, notes, and snippets.

@sumitngupta
Created January 20, 2014 22:20
Show Gist options
  • Save sumitngupta/8530426 to your computer and use it in GitHub Desktop.
Save sumitngupta/8530426 to your computer and use it in GitHub Desktop.
namespace :quotes do
desc 'Import data from the TED API'
task :import_data => :environment do
print 'Sucking in quotes...'
# Hit the Quote model
still_has_data = true
page = 0
page_size = 250
while still_has_data do
quotes = Quote.save_data_from_api(page*page_size, page_size)
if quotes.length < page_size
still_has_data = false
else
page += 1
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment