Created
January 20, 2014 22:19
-
-
Save sumitngupta/8530416 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 > 0 | |
page += 1 | |
else | |
still_has_data = false | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment