Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks/batch_inviter.rake')
-rw-r--r--lib/tasks/batch_inviter.rake37
1 files changed, 19 insertions, 18 deletions
diff --git a/lib/tasks/batch_inviter.rake b/lib/tasks/batch_inviter.rake
index 1a862a4bf..47c4278cf 100644
--- a/lib/tasks/batch_inviter.rake
+++ b/lib/tasks/batch_inviter.rake
@@ -6,29 +6,30 @@ include RakeHelpers
namespace :invites do
- desc 'send a bunch of invites from a csv with rows of name, email'
-
- task :send, :filename, :number, :start do |t, args|
- puts "this task assumes the first line of your csv is just titles(1 indexed)"
- puts "MAKE SURE YOU HAVE RAN THIS ON THE RIGHT DB rake 'invites:send[filename, number, start] RAILS_ ENV=production'"
- puts Rails.env
- unless args[:filename]
- raise "please give me {filename.csv} {number of people to churn}, {where to start in the file}"
- end
-
+ desc 'send a bunch of invites from a csv with rows of name, email'
+ task :send, :number, :test do |t, args|
require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')
- filename = args[:filename]
- start = args[:start].to_i || 0
- number_of_backers = args[:number] || 1000
- offset = 1 + start
- puts "emailing #{number_of_backers.to_i} people listed in #{filename} starting at #{offset}"
+ filename = Rails.root + 'mailing_list.csv'
+ offset_filename = File.join(Rails.root, 'config', 'email_offset')
+ number_of_backers = args[:number] ? args[:number].to_i : 1000
+
+ offset = if File.exists?(offset_filename)
+ File.read(offset_filename).to_i
+ else
+ 1
+ end
+ test = !(args[:test] == 'false')
+ puts "emailing #{number_of_backers} people listed in #{filename} starting at #{offset}"
- finish_num = process_emails(filename, number_of_backers.to_i, offset)
+ finish_num = process_emails(filename, number_of_backers, offset, test)
- puts "you ended on #{offset + finish_num}"
+ new_offset = offset + finish_num + 1
+ File.open(File.join(Rails.root, 'config', 'email_offset'), 'w') do |f|
+ f.write(new_offset)
+ end
+ puts "you ended on #{new_offset}"
puts "all done"
end
-
end