Created
October 1, 2012 23:03
-
-
Save theinventor/3815067 to your computer and use it in GitHub Desktop.
Rake Task Template
This file contains hidden or 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 :some_thingy do | |
task :my_big_fixer, [:production_run] => :environment do |t, args| | |
production_run = args[:production_run] == "true" | |
ap "doing a dry run" unless production_run | |
my_logger = Logger.new("#{Rails.root}/log/my_thingy.log") | |
require 'progress_bar' | |
bar = ProgressBar.new(User.all.count) # pass the total for the progress bar | |
my_logger.info "Starting at #{Time.now}" | |
User.all.each do |user| | |
#do something if production_run | |
bar.increment! | |
my_logger.info "User: #{user.id} a thing happened" | |
end | |
my_logger.info "Ending at #{Time.now}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment