Updated both background jobs to not break HourlyJob
This commit is contained in:
parent
55372bf83d
commit
e7923dca9b
|
|
@ -16,3 +16,11 @@
|
||||||
execute "ALTER TABLE users DROP COLUMN profile_complete_reminder3_sent_at"
|
execute "ALTER TABLE users DROP COLUMN profile_complete_reminder3_sent_at"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
=begin
|
||||||
|
ALTER TABLE users ADD COLUMN profile_completed_at TIMESTAMP
|
||||||
|
CREATE INDEX index_users_on_profile_completed_at ON users USING btree (profile_completed_at)
|
||||||
|
ALTER TABLE users ADD COLUMN profile_complete_reminder1_sent_at TIMESTAMP
|
||||||
|
ALTER TABLE users ADD COLUMN profile_complete_reminder2_sent_at TIMESTAMP
|
||||||
|
ALTER TABLE users ADD COLUMN profile_complete_reminder3_sent_at TIMESTAMP
|
||||||
|
UPDATE users set profile_completed_at=NOW() WHERE users.id IN (SELECT player_id FROM musicians_instruments) OR users.id IN (SELECT player_id FROM genre_players);
|
||||||
|
end
|
||||||
|
|
@ -11,3 +11,10 @@
|
||||||
execute "ALTER TABLE users DROP COLUMN gear_setup_reminder3_sent_at"
|
execute "ALTER TABLE users DROP COLUMN gear_setup_reminder3_sent_at"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
=begin
|
||||||
|
ALTER TABLE users ADD COLUMN gear_setup_reminder1_sent_at TIMESTAMP;
|
||||||
|
ALTER TABLE users ADD COLUMN gear_setup_reminder2_sent_at TIMESTAMP;
|
||||||
|
ALTER TABLE users ADD COLUMN gear_setup_reminder3_sent_at TIMESTAMP;
|
||||||
|
end
|
||||||
|
|
@ -6,3 +6,6 @@
|
||||||
execute "ALTER TABLE users DROP COLUMN signup_survey_sent_at"
|
execute "ALTER TABLE users DROP COLUMN signup_survey_sent_at"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
=begin
|
||||||
|
ALTER TABLE users ADD COLUMN signup_survey_sent_at TIMESTAMP
|
||||||
|
=end
|
||||||
|
|
@ -120,6 +120,8 @@ require "jam_ruby/lib/subscription_message"
|
||||||
require "jam_ruby/lib/stats.rb"
|
require "jam_ruby/lib/stats.rb"
|
||||||
require "jam_ruby/lib/email_new_musician_match"
|
require "jam_ruby/lib/email_new_musician_match"
|
||||||
require "jam_ruby/lib/musician_filter"
|
require "jam_ruby/lib/musician_filter"
|
||||||
|
require "jam_ruby/lib/email_profile_reminder"
|
||||||
|
require "jam_ruby/lib/email_signup_survey"
|
||||||
require "jam_ruby/amqp/amqp_connection_manager"
|
require "jam_ruby/amqp/amqp_connection_manager"
|
||||||
require "jam_ruby/database"
|
require "jam_ruby/database"
|
||||||
require "jam_ruby/message_factory"
|
require "jam_ruby/message_factory"
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,30 @@
|
||||||
module JamRuby
|
module JamRuby
|
||||||
class EmailProfileReminder
|
class EmailProfileReminder
|
||||||
|
@@log = Logging.logger[EmailProfileReminder]
|
||||||
|
|
||||||
def self.send_reminders
|
def self.send_reminders
|
||||||
#If the user has not updated their profile 1 day after signup, then send reminder email1
|
begin
|
||||||
reminder1_users.each do |user|
|
#If the user has not updated their profile 1 day after signup, then send reminder email1
|
||||||
UserMailer.profile_complete_reminder1(user).deliver_now
|
reminder1_users.find_each do |user|
|
||||||
user.update(profile_complete_reminder1_sent_at: Time.now)
|
UserMailer.profile_complete_reminder1(user).deliver_now
|
||||||
end
|
User.where(id: user.id).update_all(profile_complete_reminder1_sent_at: Time.now)
|
||||||
|
end
|
||||||
|
|
||||||
#If the user has not updated their profile 3 days after signup, then send reminder email2
|
#If the user has not updated their profile 3 days after signup, then send reminder email2
|
||||||
reminder2_users.each do |user|
|
reminder2_users.find_each do |user|
|
||||||
UserMailer.profile_complete_reminder2(user).deliver_now
|
UserMailer.profile_complete_reminder2(user).deliver_now
|
||||||
user.update(profile_complete_reminder2_sent_at: Time.now)
|
User.where(id: user.id).update_all(profile_complete_reminder2_sent_at: Time.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
#If the user has not updated their profile 5 days after signup, then send reminder email3
|
#If the user has not updated their profile 5 days after signup, then send reminder email3
|
||||||
reminder3_users.each do |user|
|
reminder3_users.find_each do |user|
|
||||||
UserMailer.profile_complete_reminder3(user).deliver_now
|
UserMailer.profile_complete_reminder3(user).deliver_now
|
||||||
user.update(profile_complete_reminder3_sent_at: Time.now)
|
User.where(id: user.id).update_all(profile_complete_reminder3_sent_at: Time.now)
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
@@log.error("unable to send profile reminder email=#{e}")
|
||||||
|
puts "unable to send profile reminder email=#{e}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.prospect_users
|
def self.prospect_users
|
||||||
|
|
@ -27,15 +32,15 @@ module JamRuby
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.reminder1_users
|
def self.reminder1_users
|
||||||
EmailProfileReminder.prospect_users.where("users.created_at > ? AND users.profile_complete_reminder1_sent_at IS NULL", 1.day.ago)
|
EmailProfileReminder.prospect_users.where("users.created_at < ? AND users.profile_complete_reminder1_sent_at IS NULL", 1.day.ago)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.reminder2_users
|
def self.reminder2_users
|
||||||
EmailProfileReminder.prospect_users.where("users.created_at > ? AND users.profile_complete_reminder1_sent_at IS NOT NULL AND users.profile_complete_reminder2_sent_at IS NULL", 3.days.ago)
|
EmailProfileReminder.prospect_users.where("users.created_at < ? AND users.profile_complete_reminder1_sent_at IS NOT NULL AND users.profile_complete_reminder2_sent_at IS NULL", 3.days.ago)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.reminder3_users
|
def self.reminder3_users
|
||||||
EmailProfileReminder.prospect_users.where("users.created_at > ? AND users.profile_complete_reminder2_sent_at IS NOT NULL AND users.profile_complete_reminder3_sent_at IS NULL", 5.days.ago)
|
EmailProfileReminder.prospect_users.where("users.created_at < ? AND users.profile_complete_reminder2_sent_at IS NOT NULL AND users.profile_complete_reminder3_sent_at IS NULL", 5.days.ago)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,17 @@
|
||||||
module JamRuby
|
module JamRuby
|
||||||
class EmailSignupSurvey
|
class EmailSignupSurvey
|
||||||
|
@@log = Logging.logger[EmailSignupSurvey]
|
||||||
|
|
||||||
def self.send_survey
|
def self.send_survey
|
||||||
# if signup survey email has not been sent to this user, then send it
|
begin
|
||||||
survey_users.each do |user|
|
# if signup survey email has not been sent to this user, then send it
|
||||||
UserMailer.signup_survey(user).deliver_now
|
survey_users.find_each do |user|
|
||||||
user.update(signup_survey_sent_at: Time.now)
|
UserMailer.signup_survey(user).deliver_now
|
||||||
|
User.where(id: user.id).update_all(signup_survey_sent_at: Time.now)
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
@@log.error("unable to send surevy email e=#{e}")
|
||||||
|
puts "unable to send surevy email e=#{e}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,10 @@ module JamRuby
|
||||||
#TeacherPayment.hourly_check
|
#TeacherPayment.hourly_check
|
||||||
User.hourly_check
|
User.hourly_check
|
||||||
AffiliatePartner.tally_up(Date.today)
|
AffiliatePartner.tally_up(Date.today)
|
||||||
EmailProfileReminder.send_reminders
|
|
||||||
|
# bring me back in once tested profile_completed_at is set somewhere
|
||||||
|
#EmailProfileReminder.send_reminders
|
||||||
|
|
||||||
EmailSignupSurvey.send_survey
|
EmailSignupSurvey.send_survey
|
||||||
ConnectionManager.new.cleanup_dangling
|
ConnectionManager.new.cleanup_dangling
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue