wip
This commit is contained in:
parent
7485271573
commit
91d60f5e01
1 changed files with 31 additions and 20 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
module CsvGenerator
|
module CsvGenerator
|
||||||
|
|
||||||
PATH = '/usr/local/app/diaspora'
|
PATH = '/home/ilya/workspace/diaspora/'
|
||||||
BACKER_CSV_LOCATION = File.join('/usr/local/app/diaspora/', 'backer_list.csv')
|
BACKER_CSV_LOCATION = File.join('/home/ilya/workspace/diaspora/', 'backer_list.csv')
|
||||||
WAITLIST_LOCATION = File.join(Rails.root, 'config', 'mailing_list.csv')
|
WAITLIST_LOCATION = File.join(Rails.root, 'config', 'mailing_list.csv')
|
||||||
OFFSET_LOCATION = File.join(Rails.root, 'config', 'email_offset')
|
OFFSET_LOCATION = File.join(Rails.root, 'config', 'email_offset')
|
||||||
|
|
||||||
|
|
@ -31,34 +31,45 @@ SQL
|
||||||
|
|
||||||
def self.backers_recent_login
|
def self.backers_recent_login
|
||||||
file = self.filename("v1_backers_recent_login.csv")
|
file = self.filename("v1_backers_recent_login.csv")
|
||||||
|
# coalesce( `profiles`.full_name, )
|
||||||
|
# JOIN ( `profiles`.)
|
||||||
sql = <<SQL
|
sql = <<SQL
|
||||||
SELECT email AS '%EMAIL%',
|
SELECT `users`.email AS '%EMAIL%',
|
||||||
coalesce( full_name, 'friend of Diaspora*') AS '%NAME%',
|
'friend of Diaspora*' AS '%NAME%',
|
||||||
invitation_token AS '%TOKEN%'
|
`users`.invitation_token AS '%TOKEN%'
|
||||||
#{self.output_syntax(file)}
|
#{self.output_syntax(file)}
|
||||||
FROM `users`
|
FROM `users`
|
||||||
WHERE #{self.backer_email_condition}
|
WHERE #{self.backer_email_condition}
|
||||||
AND (last_sign_in_at >= #{(Time.now - 1.month).to_i})
|
AND (last_sign_in_at > 1312675027);
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
|
puts "Here is the sql:"
|
||||||
|
puts sql
|
||||||
|
puts
|
||||||
|
|
||||||
|
User.connection.execute(sql)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.backers_older_login
|
# def self.backers_older_login
|
||||||
file = self.filename("v1_backers_recent_login.csv")
|
# file = self.filename("v1_backers_recent_login.csv")
|
||||||
sql = <<SQL
|
# sql = <<SQL
|
||||||
SELECT email AS '%EMAIL%',
|
# SELECT email AS '%EMAIL%',
|
||||||
coalesce( full_name, 'friend of Diaspora*') AS '%NAME%',
|
# coalesce( full_name, 'friend of Diaspora*') AS '%NAME%',
|
||||||
invitation_token AS '%TOKEN%'
|
# invitation_token AS '%TOKEN%'
|
||||||
#{self.output_syntax(file)}
|
# #{self.output_syntax(file)}
|
||||||
FROM `users`
|
# FROM `users`
|
||||||
WHERE #{self.backer_email_condition}
|
# WHERE #{self.backer_email_condition}
|
||||||
AND (last_sign_in_at < #{(Time.now - 1.month).to_i})
|
# AND (last_sign_in_at < #{(Time.now - 1.month).to_i})
|
||||||
SQL
|
#SQL
|
||||||
end
|
# ActiveRecord::Base.execute(sql)
|
||||||
|
# end
|
||||||
|
|
||||||
|
|
||||||
# ---------------- QUERY METHODS & NOTES -------------------------
|
# ---------------- QUERY METHODS & NOTES -------------------------
|
||||||
def self.backer_email_condition
|
def self.backer_email_condition
|
||||||
"`users`.`email` IN (#{query_string_from_array(self.backer_emails)})"
|
b_emails = self.backer_emails
|
||||||
|
b_emails.map!{|a| "'#{a}'"}
|
||||||
|
"`users`.`email` IN (#{query_string_from_array(b_emails[1..b_emails.length])})"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.recent_login_query
|
def self.recent_login_query
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue