if Rails.env.development?
  Rails.logger = Logger.new(STDOUT)
end


namespace :users do

  desc "Send new musicians in your area emails to all users"
  task :new_musician_email, [:since_date] => :environment do |task, args|
    since_date = Date.strptime(args[:since_date]) rescue nil
    User.deliver_new_musician_notifications(since_date)
  end

  desc "Fix corrupted country codes"
  task :fix_corrupted_country_codes do |task, args|
    User.where(["country like ?","{:country%"]).find_each do |uu|
      if uu.country =~ /{:countrycode=>"([A-Z]+)",/
        uu.update_attribute(:country,$1)
      end
    end
  end

  task :update_profile_pct do |task, args|
    Teacher.all.each do |teacher|
      teacher.update_profile_pct
    end
  end

end
