From e44ccc76532bc58a1c292291b8e75e3c1938cc43 Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Mon, 19 May 2014 15:12:59 +0000 Subject: [PATCH] VRFS-736 client_notdl mailer --- db/up/periodic_emails.sql | 3 +++ ruby/lib/jam_ruby.rb | 1 + .../jam_ruby/app/mailers/progress_mailer.rb | 23 +++++++++++-------- .../progress_mailer/client_notdl.html.erb | 18 +++++++++++++++ .../progress_mailer/client_notdl.text.erb | 11 +++++++++ .../models/email_batch_progression.rb | 22 ++++++++---------- ruby/lib/jam_ruby/models/email_batch_set.rb | 4 ++-- web/app/controllers/users_controller.rb | 4 ++-- 8 files changed, 59 insertions(+), 27 deletions(-) create mode 100644 ruby/lib/jam_ruby/app/views/jam_ruby/progress_mailer/client_notdl.html.erb create mode 100644 ruby/lib/jam_ruby/app/views/jam_ruby/progress_mailer/client_notdl.text.erb diff --git a/db/up/periodic_emails.sql b/db/up/periodic_emails.sql index b67864d84..ed7d091f9 100644 --- a/db/up/periodic_emails.sql +++ b/db/up/periodic_emails.sql @@ -10,3 +10,6 @@ ALTER TABLE email_batch_sets ADD COLUMN user_id VARCHAR(64); CREATE INDEX email_batch_sets_progress_idx ON email_batch_sets(user_id, sub_type); CREATE INDEX users_musician_email_idx ON users(subscribe_email, musician); + +UPDATE users set first_social_promoted_at = first_liked_us; +ALTER TABLE users DROP column first_liked_us; \ No newline at end of file diff --git a/ruby/lib/jam_ruby.rb b/ruby/lib/jam_ruby.rb index 9d74fc4ac..34fa48f0b 100755 --- a/ruby/lib/jam_ruby.rb +++ b/ruby/lib/jam_ruby.rb @@ -145,6 +145,7 @@ require "jam_ruby/models/email_batch_set" require "jam_ruby/models/email_error" require "jam_ruby/app/mailers/async_mailer" require "jam_ruby/app/mailers/batch_mailer" +require "jam_ruby/app/mailers/progress_mailer" require "jam_ruby/models/affiliate_partner" require "jam_ruby/models/chat_message" diff --git a/ruby/lib/jam_ruby/app/mailers/progress_mailer.rb b/ruby/lib/jam_ruby/app/mailers/progress_mailer.rb index 86ab65b36..789b50716 100644 --- a/ruby/lib/jam_ruby/app/mailers/progress_mailer.rb +++ b/ruby/lib/jam_ruby/app/mailers/progress_mailer.rb @@ -7,16 +7,19 @@ module JamRuby sendgrid_unique_args :env => Environment.mode default :from => UserMailer::DEFAULT_SENDER - def progress_reminder(batch_set) - sendgrid_recipients([user.email]) - sendgrid_substitute('@USERID', [user.id]) - mail(:to => batch_set.user.email, - :subject => batch_set.subject, - :title => batch_set.title, - :template_name => batch_set.sub_type) do |format| - format.text - format.html - end + def send_reminder(batch_set) + user = batch_set.user + + sendgrid_recipients([user.email]) + sendgrid_substitute('@USERID', [user.id]) + sendgrid_substitute(EmailBatchProgression::VAR_FIRST_NAME, [user.first_name]) + + mail(:to => user.email, + :subject => batch_set.subject, + :title => batch_set.title) do |format| + format.text { render batch_set.sub_type } + format.html { render batch_set.sub_type } + end end end diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/progress_mailer/client_notdl.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/progress_mailer/client_notdl.html.erb new file mode 100644 index 000000000..cb221e5c9 --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/progress_mailer/client_notdl.html.erb @@ -0,0 +1,18 @@ +<% provide(:title, @title) %> + +

Hello <%= EmailBatchProgression::VAR_FIRST_NAME %> -- +

+ +

We noticed that you have registered as a JamKazam musician, but you have not yet downloaded and started using the free JamKazam application. You can find other musicians and listen to sessions and recordings on our website, but you need the free JamKazam application to play with other musicians online. Please click the link below to go to the download page for the free JamKazam application, or visit our JamKazam support center so that we can help you get up and running. +

+ +

+Go to Download Page +

+ +

+Go to Support Center +

+ +

-- Team JamKazam +

diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/progress_mailer/client_notdl.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/progress_mailer/client_notdl.text.erb new file mode 100644 index 000000000..cb5d3dbaa --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/progress_mailer/client_notdl.text.erb @@ -0,0 +1,11 @@ +<% provide(:title, @title) %> + +Hello <%= EmailBatchProgression::VAR_FIRST_NAME %> -- + +We noticed that you have registered as a JamKazam musician, but you have not yet downloaded and started using the free JamKazam application. You can find other musicians and listen to sessions and recordings on our website, but you need the free JamKazam application to play with other musicians online. Please click the link below to go to the download page for the free JamKazam application, or visit our JamKazam support center so that we can help you get up and running. + +Go to Download Page: http://www.jamkazam.com/downloads + +Go to Support Center: https://jamkazam.desk.com + +-- Team JamKazam diff --git a/ruby/lib/jam_ruby/models/email_batch_progression.rb b/ruby/lib/jam_ruby/models/email_batch_progression.rb index eaccebe2e..5f814d24f 100644 --- a/ruby/lib/jam_ruby/models/email_batch_progression.rb +++ b/ruby/lib/jam_ruby/models/email_batch_progression.rb @@ -81,25 +81,21 @@ module JamRuby def trigger_date_constraint(trigger_idx) intervals = self.class.subtype_trigger_interval(self.sub_type) + date_constraint = Time.now - intervals[trigger_idx].days + case self.sub_type.to_sym - when :client_notdl - return ["users.created_at < ?", Time.now - intervals[trigger_idx].days] + when :client_notdl, :reg_notconnect, :reg_notinvite, :reg_notlike + return ["users.created_at < ?", date_constraint] when :client_dl_notrun - return ["users.first_downloaded_client_at < ?", Time.now - intervals[trigger_idx].days] + return ["users.first_downloaded_client_at < ?", date_constraint] when :client_run_notgear - return ["users.first_ran_client_at < ?", Time.now - intervals[trigger_idx].days] + return ["users.first_ran_client_at < ?", date_constraint] when :gear_notsess - return ["users.first_certified_gear_at < ?", Time.now - intervals[trigger_idx].days] + return ["users.first_certified_gear_at < ?", date_constraint] when :sess_notgood - return ["users.first_real_music_session_at < ?", Time.now - intervals[trigger_idx].days] + return ["users.first_real_music_session_at < ?", date_constraint] when :sess_notrecord - return ["users.first_real_music_session_at < ?", Time.now - intervals[trigger_idx].days] - when :reg_notconnect - return ["users.created_at < ?", Time.now - intervals[trigger_idx].days] - when :reg_notinvite - return ["users.created_at < ?", Time.now - intervals[trigger_idx].days] - when :reg_notlike - return ["users.created_at < ?", Time.now - intervals[trigger_idx].days] + return ["users.first_real_music_session_at < ?", date_constraint] end end diff --git a/ruby/lib/jam_ruby/models/email_batch_set.rb b/ruby/lib/jam_ruby/models/email_batch_set.rb index 712224d81..cdb963ad4 100644 --- a/ruby/lib/jam_ruby/models/email_batch_set.rb +++ b/ruby/lib/jam_ruby/models/email_batch_set.rb @@ -29,14 +29,14 @@ module JamRuby def subject unless sub_type.blank? - return EmailBatchProgression.subject(self.sub_type) + return EmailBatchProgression.subject(self.sub_type.to_sym) end '' end def title unless sub_type.blank? - return EmailBatchProgression.title(self.sub_type) + return EmailBatchProgression.title(self.sub_type.to_sym) end '' end diff --git a/web/app/controllers/users_controller.rb b/web/app/controllers/users_controller.rb index ed67b405c..8fa2cc381 100644 --- a/web/app/controllers/users_controller.rb +++ b/web/app/controllers/users_controller.rb @@ -371,8 +371,8 @@ class UsersController < ApplicationController def endorse if uu = current_user || - uu = User.where(['id = ? AND first_liked_us IS NULL',params[:id]]).limit(1).first - uu.first_liked_us = Time.now + uu = User.where(['id = ? AND first_social_promoted_at IS NULL',params[:id]]).limit(1).first + uu.first_social_promoted_at = Time.now uu.save! end if params[:id].present? && (service=params[:service]).present?