made the links https and made sure we pull back users with emails
This commit is contained in:
parent
dabbeaa792
commit
8bb19288f5
1 changed files with 17 additions and 12 deletions
|
|
@ -1,7 +1,8 @@
|
||||||
module CsvGenerator
|
module CsvGenerator
|
||||||
|
|
||||||
PATH = '/tmp/csvs'
|
PATH = '/tmp/'
|
||||||
BACKER_CSV_LOCATION = File.join('/usr/local/app/diaspora/', 'backer_list.csv')
|
#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')
|
||||||
|
|
||||||
|
|
@ -30,7 +31,7 @@ SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.generate_csvs
|
def self.generate_csvs
|
||||||
`mkdir /tmp/csvs`
|
#`mkdir /tmp/csvs`
|
||||||
self.backers_recent_login
|
self.backers_recent_login
|
||||||
self.backers_old_login
|
self.backers_old_login
|
||||||
self.backers_never_login
|
self.backers_never_login
|
||||||
|
|
@ -41,14 +42,14 @@ 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")
|
||||||
sql = self.select_fragment(file, "#{self.backer_email_condition} AND #{self.recent_login_query}")
|
sql = self.select_fragment(file, "#{self.has_email} AND #{self.backer_email_condition} AND #{self.recent_login_query}")
|
||||||
|
|
||||||
ActiveRecord::Base.connection.execute(sql)
|
ActiveRecord::Base.connection.execute(sql)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.backers_old_login
|
def self.backers_old_login
|
||||||
file = self.filename("v2_backers_old_login.csv")
|
file = self.filename("v2_backers_old_login.csv")
|
||||||
sql = self.select_fragment(file, "#{self.backer_email_condition} AND #{self.old_login_query}")
|
sql = self.select_fragment(file, "#{self.has_email} AND #{self.backer_email_condition} AND #{self.old_login_query}")
|
||||||
|
|
||||||
ActiveRecord::Base.connection.execute(sql)
|
ActiveRecord::Base.connection.execute(sql)
|
||||||
end
|
end
|
||||||
|
|
@ -60,10 +61,10 @@ SQL
|
||||||
UNION
|
UNION
|
||||||
SELECT `users`.email AS '%EMAIL%',
|
SELECT `users`.email AS '%EMAIL%',
|
||||||
'friend of Diaspora*' AS '%NAME%',
|
'friend of Diaspora*' AS '%NAME%',
|
||||||
IF(`users`.invitation_token, CONCAT( 'http://joindiaspora.com/users/invitation/accept?invitation_token=', `users`.invitation_token) ,NULL) AS '%INVITATION_LINK%'
|
IF(`users`.invitation_token, CONCAT( 'https://joindiaspora.com/users/invitation/accept?invitation_token=', `users`.invitation_token) ,NULL) AS '%INVITATION_LINK%'
|
||||||
#{self.output_syntax(file)}
|
#{self.output_syntax(file)}
|
||||||
FROM `users`
|
FROM `users`
|
||||||
WHERE #{self.backer_email_condition} AND #{self.never_login_query};
|
WHERE #{self.has_email} AND #{self.backer_email_condition} AND #{self.never_login_query};
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
ActiveRecord::Base.connection.execute(sql)
|
ActiveRecord::Base.connection.execute(sql)
|
||||||
|
|
@ -71,14 +72,14 @@ SQL
|
||||||
|
|
||||||
def self.non_backers_recent_login
|
def self.non_backers_recent_login
|
||||||
file = self.filename("v4_non_backers_recent_login.csv")
|
file = self.filename("v4_non_backers_recent_login.csv")
|
||||||
sql = self.select_fragment(file, "#{self.non_backer_email_condition} AND #{self.recent_login_query}")
|
sql = self.select_fragment(file, "#{self.has_email} AND #{self.non_backer_email_condition} AND #{self.recent_login_query}")
|
||||||
|
|
||||||
ActiveRecord::Base.connection.execute(sql)
|
ActiveRecord::Base.connection.execute(sql)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.non_backers_old_login
|
def self.non_backers_old_login
|
||||||
file = self.filename("v5_non_backers_old_login.csv")
|
file = self.filename("v5_non_backers_old_login.csv")
|
||||||
sql = self.select_fragment(file, "#{self.non_backer_email_condition} AND #{self.old_login_query}")
|
sql = self.select_fragment(file, "#{self.has_email} AND #{self.non_backer_email_condition} AND #{self.old_login_query}")
|
||||||
|
|
||||||
ActiveRecord::Base.connection.execute(sql)
|
ActiveRecord::Base.connection.execute(sql)
|
||||||
end
|
end
|
||||||
|
|
@ -90,10 +91,10 @@ SQL
|
||||||
UNION
|
UNION
|
||||||
SELECT `users`.email AS '%EMAIL%',
|
SELECT `users`.email AS '%EMAIL%',
|
||||||
'friend of Diaspora*' AS '%NAME%',
|
'friend of Diaspora*' AS '%NAME%',
|
||||||
IF(`users`.invitation_token, CONCAT( 'http://joindiaspora.com/users/invitation/accept?invitation_token=', `users`.invitation_token) ,NULL) AS '%INVITATION_LINK%'
|
IF(`users`.invitation_token, CONCAT( 'https://joindiaspora.com/users/invitation/accept?invitation_token=', `users`.invitation_token) ,NULL) AS '%INVITATION_LINK%'
|
||||||
#{self.output_syntax(file)}
|
#{self.output_syntax(file)}
|
||||||
FROM `users`
|
FROM `users`
|
||||||
WHERE #{self.non_backer_email_condition} AND #{self.never_login_query};
|
WHERE #{self.has_email} AND #{self.non_backer_email_condition} AND #{self.never_login_query};
|
||||||
SQL
|
SQL
|
||||||
ActiveRecord::Base.connection.execute(sql)
|
ActiveRecord::Base.connection.execute(sql)
|
||||||
end
|
end
|
||||||
|
|
@ -109,7 +110,7 @@ SQL
|
||||||
SELECT `users`.email AS '%EMAIL%',
|
SELECT `users`.email AS '%EMAIL%',
|
||||||
IF( `profiles`.full_name IS NOT NULL AND `profiles`.full_name != "",
|
IF( `profiles`.full_name IS NOT NULL AND `profiles`.full_name != "",
|
||||||
`profiles`.full_name, 'friend of Diaspora*') AS '%NAME%',
|
`profiles`.full_name, 'friend of Diaspora*') AS '%NAME%',
|
||||||
IF(`users`.invitation_token, CONCAT( 'http://joindiaspora.com/users/invitation/accept?invitation_token=', `users`.invitation_token) ,NULL) AS '%INVITATION_LINK%'
|
IF(`users`.invitation_token, CONCAT( 'https://joindiaspora.com/users/invitation/accept?invitation_token=', `users`.invitation_token) ,NULL) AS '%INVITATION_LINK%'
|
||||||
#{self.output_syntax(file)}
|
#{self.output_syntax(file)}
|
||||||
FROM `users`
|
FROM `users`
|
||||||
JOIN `people` ON `users`.id = `people`.owner_id JOIN `profiles` ON `people`.id = `profiles`.person_id
|
JOIN `people` ON `users`.id = `people`.owner_id JOIN `profiles` ON `people`.id = `profiles`.person_id
|
||||||
|
|
@ -117,6 +118,10 @@ SQL
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.has_email
|
||||||
|
'`users`.`email` IS NOT NULL AND `users`.`email` != ""'
|
||||||
|
end
|
||||||
|
|
||||||
def self.backer_email_condition
|
def self.backer_email_condition
|
||||||
b_emails = self.backer_emails
|
b_emails = self.backer_emails
|
||||||
b_emails.map!{|a| "'#{a}'"}
|
b_emails.map!{|a| "'#{a}'"}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue