diff --git a/lib/csv_generator.rb b/lib/csv_generator.rb index de12bccf2..fb281260b 100644 --- a/lib/csv_generator.rb +++ b/lib/csv_generator.rb @@ -1,6 +1,9 @@ module CsvGenerator - PATH = '/Users/maxwell/Sites/dump' + PATH = '/usr/local/app/diaspora' + BACKER_CSV_LOCATION = File.join('/usr/local/app/diaspora/', 'backer_list.csv') + WAITLIST_LOCATION = File.join(Rails.root, 'config', 'mailing_list.csv') + OFFSET_LOCATION = File.join(Rails.root, 'config', 'email_offset') def self.all_active_users file = self.filename("all_active_users") @@ -26,20 +29,61 @@ SQL ActiveRecord::Base.execute(sql) end - def self.waitlist - filename = File.join(Rails.root, 'config', 'mailing_list.csv') - - people = self.load_waiting_list_csv - offset = self.offset - left = people[0...offset] - right = people[offset...people.size] - - #reading from csv (get number of row we're on) - left - #reading from csv (get number of row we're on) - right + def self.backers_recent_login + file = self.filename("v1_backers_recent_login.csv") + sql = <= #{(Time.now - 1.month).to_i}) +SQL end - def self.load_waiting_list_csv - csv= File.join(Rails.root, 'config', 'mailing_list.csv') + def self.backers_older_login + file = self.filename("v1_backers_recent_login.csv") + sql = < ?", (Time.now - 1.month).to_i).where(:email => ["maxwell@joindiaspora.com"]).count + # + # "SELECT `users`.* FROM `users` WHERE `users`.`email` IN ('maxwell@joindiaspora.com') AND (last_sign_in_at > 1312663724)" + + # NON BACKER RECENT LOGIN + # User.where("last_sign_in_at > ?", (Time.now - 1.month).to_i).where("email NOT IN (?)", 'maxwell@joindiaspora.com').to_sql + # "SELECT `users`.* FROM `users` WHERE (last_sign_in_at > 1312665370) AND (email NOT IN ('maxwell@joindiaspora.com'))" + + + + + # ---------------- HELPER METHODS ------------------------- + def self.load_waiting_list_csv(filename) + csv = filename if RUBY_VERSION.include? "1.8" require 'fastercsv' people = FasterCSV.read(csv) @@ -51,7 +95,7 @@ SQL end def self.offset - offset_filename = File.join(Rails.root, 'config', 'email_offset') + offset_filename = OFFSET_LOCATION File.read(offset_filename).to_i end @@ -66,4 +110,22 @@ FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' SQL end + + def self.waitlist + people = self.load_waiting_list_csv(WAITLIST_LOCATION) + offset = self.offset + left = people[0...offset] + right = people[offset...people.size] + + #reading from csv (get number of row we're on) - left + #reading from csv (get number of row we're on) - right + end + + def self.backers + self.load_waiting_list_csv(BACKER_CSV_LOCATION) + end + + def self.backer_emails + self.backers.map{|b| b[0]} + end end