emails ready to go for amazonv2
This commit is contained in:
parent
b0ccb5202e
commit
57764a3aba
|
|
@ -3,7 +3,15 @@
|
|||
ALTER TABLE users ADD COLUMN first_lesson_booked_at TIMESTAMP WITHOUT TIME ZONE;
|
||||
ALTER TABLE users ADD COLUMN remind_take_lesson_times INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE users ADD COLUMN remind_take_lesson_at TIMESTAMP WITHOUT TIME ZONE;
|
||||
ALTER TABLE users ADD COLUMN sent_first_lesson_instr_email_at TIMESTAMP WITHOUT TIME ZONE;
|
||||
ALTER TABLE lesson_sessions ADD COLUMN sent_early_starting_notice BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
CREATE INDEX index_remind_take_lesson_times ON users USING btree(remind_take_lesson_times);
|
||||
CREATE INDEX index_sent_first_lesson_instr_email_at ON users USING btree(sent_first_lesson_instr_email_at);
|
||||
CREATE INDEX index_sent_early_starting_notice ON lesson_sessions USING btree(sent_early_starting_notice);
|
||||
CREATE INDEX index_sen_starting_notice ON lesson_sessions USING btree(sent_starting_notice);
|
||||
|
||||
|
||||
|
||||
-- bootstrap first_lesson_booked_at
|
||||
UPDATE users SET first_lesson_booked_at = (SELECT lesson_sessions.created_at FROM lesson_sessions WHERE users.id = lesson_sessions.user_id ORDER BY lesson_sessions.created_at LIMIT 1);
|
||||
|
|
@ -2080,7 +2080,8 @@ module JamRuby
|
|||
end
|
||||
|
||||
|
||||
def lesson_starting_soon_teacher(lesson_session)
|
||||
def lesson_starting_soon_teacher(lesson_session, early_notice, time_stmt)
|
||||
@early_notice = early_notice
|
||||
@lesson_booking = lesson_booking = lesson_session.lesson_booking
|
||||
@student = lesson_booking.student
|
||||
@teacher = lesson_booking.teacher
|
||||
|
|
@ -2088,10 +2089,20 @@ module JamRuby
|
|||
@session_name = @lesson_session.music_session.name
|
||||
@session_description = @lesson_session.music_session.description
|
||||
@session_date = @lesson_session.slot.pretty_scheduled_start(true)
|
||||
if @student.anonymous?
|
||||
@student_name = 'a student'
|
||||
else
|
||||
@student_name = @student.name
|
||||
end
|
||||
|
||||
@user = @teacher
|
||||
email = @teacher.email
|
||||
@subject = "Your lesson with #{@student.first_name} on JamKazam is starting soon"
|
||||
if early_notice
|
||||
@subject = "Your JamKazam lesson starts in 2 hours at #{time_stmt}"
|
||||
else
|
||||
@subject = "Your JamKazam lesson starts in 30 minutes at #{time_stmt}"
|
||||
end
|
||||
|
||||
unique_args = {:type => "send_starting_notice_teacher"}
|
||||
|
||||
sendgrid_category "Notification"
|
||||
|
|
@ -2105,7 +2116,8 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
def lesson_starting_soon_student(lesson_session)
|
||||
def lesson_starting_soon_student(lesson_session, early_notice, time_stmt)
|
||||
@early_notice = early_notice
|
||||
@lesson_booking = lesson_booking = lesson_session.lesson_booking
|
||||
@student = lesson_booking.student
|
||||
@teacher = lesson_booking.teacher
|
||||
|
|
@ -2115,8 +2127,18 @@ module JamRuby
|
|||
@session_description = @lesson_session.music_session.description
|
||||
@session_date = @lesson_session.slot.pretty_scheduled_start(true)
|
||||
@user = @student
|
||||
if @student.anonymous?
|
||||
@student_name = 'a student'
|
||||
else
|
||||
@student_name = @student.name
|
||||
end
|
||||
email = @student.email
|
||||
@subject = "Your lesson with #{@teacher.first_name} on JamKazam is starting soon"
|
||||
if early_notice
|
||||
@subject = "Your JamKazam lesson starts in 2 hours at #{time_stmt}"
|
||||
else
|
||||
@subject = "Your JamKazam lesson starts in 30 minutes at #{time_stmt}"
|
||||
end
|
||||
|
||||
unique_args = {:type => "send_starting_notice_student"}
|
||||
|
||||
sendgrid_category "Notification"
|
||||
|
|
@ -2189,6 +2211,7 @@ module JamRuby
|
|||
else
|
||||
@subject = "Last reminder to schedule your first free lesson!"
|
||||
end
|
||||
@book_lesson_link = "#{APP_CONFIG.external_root_url}/client#/jamclass/book-lesson/test-drive_#{@teacher.id}"
|
||||
|
||||
|
||||
unique_args = {:type => "amazon_prompt_take_lesson"}
|
||||
|
|
@ -2202,5 +2225,37 @@ module JamRuby
|
|||
format.html {render :layout => "raw_mailer"}
|
||||
end
|
||||
end
|
||||
|
||||
def amazon_first_lesson_scheduled(user)
|
||||
@user = user
|
||||
@subject = "IMPORTANT - instructions to be ready for your first lesson!"
|
||||
email = user.email
|
||||
|
||||
unique_args = {:type => "amazon_first_lesson_scheduled"}
|
||||
|
||||
sendgrid_category "amazon_first_lesson_scheduled"
|
||||
sendgrid_unique_args :type => unique_args[:type]
|
||||
sendgrid_recipients([email])
|
||||
mail(:to => email, :subject => @subject) do |format|
|
||||
format.text
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def amazon_first_lesson_instructions(user)
|
||||
@user = user
|
||||
@subject = "How to join your first lesson"
|
||||
email = user.email
|
||||
|
||||
unique_args = {:type => "amazon_first_lesson_instructions"}
|
||||
|
||||
sendgrid_category "amazon_first_lesson_instructions"
|
||||
sendgrid_unique_args :type => unique_args[:type]
|
||||
sendgrid_recipients([email])
|
||||
mail(:to => email, :subject => @subject) do |format|
|
||||
format.text
|
||||
format.html
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
<% provide(:title, @subject) %>
|
||||
|
||||
<p>
|
||||
Your first free lesson is just a couple of days away now!
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Here is a help article that explains how to join the lesson when it's time for it to start: <a href="https://bit.ly/2BzKUMk" style="color:#fc0">https://bit.ly/2BzKUMk</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
And here is a link to a set of help articles for students that may want to review when you have a little free time. These help articles review all of the key features of JamKazam's online music lessons service and can help you get the most our of our platform and your lessons: <a href="https://bit.ly/2iytkQP" style="color:#fc0">https://bit.ly/2iytkQP</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
We hope you have a great lesson!
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif">
|
||||
Best Regards,<br/>
|
||||
Team JamKazam
|
||||
</font>
|
||||
</p>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
Your first free lesson is just a couple of days away now!
|
||||
|
||||
Here is a help article that explains how to join the lesson when it's time for it to start: https://bit.ly/2BzKUMk
|
||||
|
||||
And here is a link to a set of help articles for students that may want to review when you have a little free time. These help articles review all of the key features of JamKazam's online music lessons service and can help you get the most our of our platform and your lessons: https://bit.ly/2iytkQP
|
||||
|
||||
We hope you have a great lesson!
|
||||
|
||||
Best Regards,
|
||||
Team JamKazam
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<% provide(:title, @subject) %>
|
||||
|
||||
<p>
|
||||
Now that you've scheduled your first free lesson, you need to make sure you are ready for it. This involves installing the JamKazam application on your computer and running through a quick configuration wizard. You may also need to buy a $9.99 USB guitar cable from Amazon if you have an electric or bass guitar with no amplifier.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Please do not put off getting ready until the last minute, or you won't be ready, and you'll waste one of your free lessons! Click on the button below for either Windows or Mac computer instructions. These help articles will make sure you have everything you need, and will give you step-by-step instructions to get set up and ready to go.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif"><a href="https://jamkazam.desk.com/customer/portal/articles/2937908-setup-instructions-for-windows-computers" style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">Instructions for Windows Computers</a></font> <font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif"><a href="https://jamkazam.desk.com/customer/portal/articles/2937909-setup-instructions-for-mac-computers"style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">Instructions for Mac Computers</a></font>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you have any questions or problems, don't hesitate to reach out to us for help at <a href="mailto:support@jamkazam.com" style="color: #ffcc00;">support@jamkazam.com</a>.
|
||||
</p>
|
||||
<p>
|
||||
<font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif">
|
||||
Best Regards,<br/>
|
||||
Team JamKazam
|
||||
</font>
|
||||
</p>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
Now that you've scheduled your first free lesson, you need to make sure you are ready for it. This involves installing the JamKazam application on your computer and running through a quick configuration wizard. You may also need to buy a $9.99 USB guitar cable from Amazon if you have an electric or bass guitar with no amplifier.
|
||||
|
||||
Please do not put off getting ready until the last minute, or you won't be ready, and you'll waste one of your free lessons! Click on the button below for either Windows or Mac computer instructions. These help articles will make sure you have everything you need, and will give you step-by-step instructions to get set up and ready to go.
|
||||
|
||||
Instructions for Windows Computers (https://jamkazam.desk.com/customer/portal/articles/2937908-setup-instructions-for-windows-computers)
|
||||
Instructions for Mac Computers (https://jamkazam.desk.com/customer/portal/articles/2937909-setup-instructions-for-mac-computers)
|
||||
|
||||
If you have any questions or problems, don't hesitate to reach out to us for help at support@jamkazam.com.
|
||||
|
||||
Best Regards,
|
||||
Team JamKazam
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<p style="text-align:center"><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif"><a href="<%= %>"style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">SCHEDULE FIRST FREE LESSON NOW</a></font></p>
|
||||
<p style="text-align:center"><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif"><a href="<%= @book_lesson_link %>"style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">SCHEDULE FIRST FREE LESSON NOW</a></font></p>
|
||||
<br>
|
||||
<p><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif">Click the button to schedule your first free lesson with the instructor listed above! Or if you think you'd prefer a different instructor, <a style="color: #ffcc00;" href="<%= User.search_url %>">click here</a> to search our guitar and bass instructors to select a different one.</font></p>
|
||||
<p><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif">To take online lessons, you'll need:</font></p>
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<p style="text-align:center"><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif"><a href="<%= %>"style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">SCHEDULE FIRST FREE LESSON NOW</a></font></p>
|
||||
<p style="text-align:center"><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif"><a href="<%= @book_lesson_link %>"style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">SCHEDULE FIRST FREE LESSON NOW</a></font></p>
|
||||
<br>
|
||||
<p><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif">Click the button to schedule your first free lesson with the instructor listed above! Or if you think you'd prefer a different instructor, <a style="color: #ffcc00;" href="<%= User.search_url %>">click here</a> to search our guitar and bass instructors to select a different one.</font></p>
|
||||
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<p style="text-align:center"><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif"><a href="<%= %>"style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">SCHEDULE FIRST FREE LESSON NOW</a></font></p>
|
||||
<p style="text-align:center"><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif"><a href="<%= @book_lesson_link %>"style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">SCHEDULE FIRST FREE LESSON NOW</a></font></p>
|
||||
<br>
|
||||
<p><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif">Click the button to schedule your first free lesson with the instructor listed above! Or if you think you'd prefer a different instructor, <a style="color: #ffcc00;" href="<%= User.search_url %>">click here</a> to search our guitar and bass instructors to select a different one.</font></p>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
<% if @attempt == 0 %>
|
||||
Welcome to JamKazam, and congratulations on your free private music lessons, courtesy of Amazon! Here is a great instructor we can recommend to you:
|
||||
|
||||
Suggested teacher: <%= @teacher.name %>
|
||||
Teacher bio: <%= @biography %>
|
||||
|
||||
SCHEDULE FIRST FREE LESSON NOW! (<%= @book_lesson_link %>)
|
||||
|
||||
Click the button to schedule your first free lesson with the instructor listed above! Or if you think you'd prefer a different instructor, click here (<%= User.search_url %>) to search our guitar and bass instructors to select a different one.
|
||||
To take online lessons, you'll need:
|
||||
* A Windows or Mac computer
|
||||
* A webcam, a microphone, and a port to connect headphones or earbuds (all three are usually built into your computer)
|
||||
* Internet service at your home
|
||||
|
||||
Schedule your first free lesson now to get started. And if you have any questions, don't hesitate to contact us by email at support@jamkazam.com. We are here to make your musical journey a rewarding one!
|
||||
|
||||
<% elsif @attempt == 1 %>
|
||||
Just a quick reminder - don't forget to schedule your first free lesson! Here is another great instructor we can recommend to you:
|
||||
|
||||
Suggested teacher: <%= @teacher.name %>
|
||||
Teacher bio: <%= @biography %>
|
||||
|
||||
SCHEDULE FIRST FREE LESSON NOW! (<%= @book_lesson_link %>)
|
||||
|
||||
Click the button to schedule your first free lesson with the instructor listed above! Or if you think you'd prefer a different instructor, click here (<%= User.search_url %>) to search our guitar and bass instructors to select a different one.
|
||||
If you have any questions, don't hesitate to contact us by email at support@jamkazam.com.
|
||||
|
||||
<% else %>
|
||||
We don't want to bother you, so just sending one more reminder. A private instructor is by far the best way to learn a new instrument. Here is another great instructor we can recommend to you:
|
||||
|
||||
Suggested teacher: <%= @teacher.name %>
|
||||
Teacher bio: <%= @biography %>
|
||||
|
||||
SCHEDULE FIRST FREE LESSON NOW! (<%= @book_lesson_link %>)
|
||||
|
||||
Click the button to schedule your first free lesson with the instructor listed above! Or if you think you'd prefer a different instructor, click here (<%= User.search_url %>) to search our guitar and bass instructors to select a different one.
|
||||
If you have any questions, don't hesitate to contact us by email at support@jamkazam.com.
|
||||
<% end %>
|
||||
|
||||
|
||||
Best Regards,
|
||||
Team JamKazam
|
||||
|
|
@ -3,10 +3,24 @@
|
|||
|
||||
<% content_for :note do %>
|
||||
<p>
|
||||
Your lesson with <%= @teacher.name %> is scheduled to begin on JamKazam in less than 30 minutes.
|
||||
<p>
|
||||
<a href="<%= @lesson_session.home_url %>" style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">JAMCLASS HOME</a>
|
||||
<%= @student.greetings %>
|
||||
</p>
|
||||
|
||||
<% if @early_notice %>
|
||||
<p>
|
||||
You are scheduled to take a lesson on JamKazam from <%= @teacher.name %> very soon. We suggest that you start up the JamKazam application and make sure all your audio gear is set up and ready to go 10 minutes before the lesson's start time - just in case the application needs to update itself or you run into any other unexpected problems.
|
||||
</p>
|
||||
<p>
|
||||
Just in case you don't remember how to join your lesson, here is a link to a help article that explains how to do this: <a href="https://bit.ly/2BzKUMk" style="color:#fc0">https://bit.ly/2BzKUMk</a>.
|
||||
</p>
|
||||
<% else %>
|
||||
<p>
|
||||
Your lesson with <%= @teacher.name %> is scheduled to begin on JamKazam in less than 30 minutes.
|
||||
<p>
|
||||
<a href="<%= @lesson_session.home_url %>" style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">JAMCLASS HOME</a>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,14 @@
|
|||
<%= @student.greetings %>
|
||||
<% if @early_notice %>
|
||||
You are scheduled to take a lesson on JamKazam from <%= @teacher.name %> very soon. We suggest that you start up the JamKazam application and make sure all your audio gear is set up and ready to go 10 minutes before the lesson's start time - just in case the application needs to update itself or you run into any other unexpected problems.
|
||||
|
||||
Just in case you don't remember how to join your lesson, here is a link to a help article that explains how to do this: https://bit.ly/2BzKUMk.
|
||||
<% else %>
|
||||
Your lesson with <%= @teacher.name %> is scheduled to begin on JamKazam in less than 30 minutes.
|
||||
|
||||
JAMCLASS HOME (<%= @lesson_session.home_url %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,23 @@
|
|||
|
||||
<% content_for :note do %>
|
||||
<p>
|
||||
Your lesson with <%= @student.name %> is scheduled to begin on JamKazam in less than 30 minutes.
|
||||
<p>
|
||||
<a href="<%= @lesson_session.home_url %>" style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">JAMCLASS HOME</a>
|
||||
<%= @teacher.greetings %>
|
||||
</p>
|
||||
|
||||
<% if @early_notice %>
|
||||
<p>
|
||||
You are scheduled to take a lesson on JamKazam from <%= @student_name %> very soon. We suggest that you start up the JamKazam application and make sure all your audio gear is set up and ready to go 10 minutes before the lesson's start time - just in case the application needs to update itself or you run into any other unexpected problems.
|
||||
</p>
|
||||
<p>
|
||||
Just in case you don't remember how to join your lesson, here is a link to a help article that explains how to do this: <a href="https://bit.ly/2BzKUMk" style="color:#fc0">https://bit.ly/2BzKUMk</a>.
|
||||
</p>
|
||||
<% else %>
|
||||
<p>
|
||||
Your lesson with <%= @student_name %> is scheduled to begin on JamKazam in less than 30 minutes.
|
||||
<p>
|
||||
<a href="<%= @lesson_session.home_url %>" style="margin: 8px 0 0 0;background-color: #ed3618;border: solid 1px #F27861;padding: 3px 10px;font-size: 12px;font-weight: 300;cursor: pointer;color: #FC9;text-decoration: none;line-height: 12px;text-align: center;">JAMCLASS HOME</a>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,15 @@
|
|||
Your lesson with <%= @student.name %> is scheduled to begin on JamKazam in less than 30 minutes.
|
||||
JAMCLASS HOME (<%= @lesson_session.home_url %>
|
||||
<%= @teacher.greetings %>
|
||||
<% if @early_notice %>
|
||||
You are scheduled to teach a lesson on JamKazam for <%= @student_name %> very soon. We suggest that you start up the JamKazam application and make sure all your audio gear is set up and ready to go 10 minutes before the lesson's start time - just in case the application needs to update itself or you run into any other unexpected problems.
|
||||
|
||||
Just in case you don't remember how to join your lesson, here is a link to a help article that explains how to do this: https://bit.ly/2BzKUMk.
|
||||
<% else %>
|
||||
Your lesson with <%= @student_name %> is scheduled to begin on JamKazam in less than 30 minutes.
|
||||
|
||||
JAMCLASS HOME (<%= @lesson_session.home_url %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ module JamRuby
|
|||
|
||||
def self.minutely_check
|
||||
upcoming_sessions_reminder
|
||||
upcoming_sessions_reminder_early
|
||||
end
|
||||
|
||||
def self.remind_counters
|
||||
|
|
@ -255,9 +256,25 @@ module JamRuby
|
|||
half_hour_from_now = Time.zone.local_to_utc(half_hour_from_now)
|
||||
end
|
||||
|
||||
|
||||
|
||||
MusicSession.joins(lesson_session: [:lesson_booking]).where('lesson_sessions.status = ?', LessonSession::STATUS_APPROVED).where('sent_starting_notice = false').where('(scheduled_start > ? and scheduled_start < ?)', now, half_hour_from_now).each do |music_session|
|
||||
lession_session = music_session.lesson_session
|
||||
lession_session.send_starting_notice
|
||||
lession_session.send_starting_notice(false)
|
||||
end
|
||||
end
|
||||
|
||||
def self.upcoming_sessions_reminder_early
|
||||
now = Time.now
|
||||
two_hours_from_now = 120.minutes.from_now
|
||||
if Time.zone
|
||||
now = Time.zone.local_to_utc(now)
|
||||
two_hours_from_now = Time.zone.local_to_utc(two_hours_from_now)
|
||||
end
|
||||
|
||||
MusicSession.joins(lesson_session: [:lesson_booking]).where('lesson_sessions.status = ?', LessonSession::STATUS_APPROVED).where('sent_starting_notice = false').where('sent_early_starting_notice = false').where('(scheduled_start > ? and scheduled_start < ?)', now, two_hours_from_now).each do |music_session|
|
||||
lession_session = music_session.lesson_session
|
||||
lession_session.send_starting_notice(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -423,11 +440,17 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
def send_starting_notice
|
||||
UserMailer.lesson_starting_soon_student(self).deliver_now
|
||||
UserMailer.lesson_starting_soon_teacher(self).deliver_now
|
||||
def send_starting_notice(early_notice)
|
||||
UserMailer.lesson_starting_soon_student(self, early_notice, student.local_hour_stmt(scheduled_start)).deliver_now
|
||||
UserMailer.lesson_starting_soon_teacher(self, early_notice, teacher.local_hour_stmt(scheduled_start)).deliver_now
|
||||
|
||||
if early_notice
|
||||
self.sent_early_starting_notice = true
|
||||
else
|
||||
self.sent_starting_notice = true
|
||||
end
|
||||
|
||||
|
||||
self.sent_starting_notice = true
|
||||
self.save(validate: false)
|
||||
end
|
||||
|
||||
|
|
@ -790,7 +813,11 @@ module JamRuby
|
|||
lesson_type = 'single paid lesson'
|
||||
end
|
||||
|
||||
User.where(id: booking.student.id).where('first_lesson_booked_at is NULL').update_all(first_lesson_booked_at: Time.now)
|
||||
updated = User.where(id: booking.student.id).where('first_lesson_booked_at is NULL').update_all(first_lesson_booked_at: Time.now)
|
||||
|
||||
if updated == 1
|
||||
UserMailer.amazon_first_lesson_scheduled(booking.student).deliver_now
|
||||
end
|
||||
|
||||
body = "Student has requested a #{lesson_type}!\n\nUser: #{booking.student.name}, #{booking.student.email}\nUser Admin URL:#{booking.student.admin_url}\n\n"
|
||||
body += "Lesson Session URL: #{lesson_session.admin_url}"
|
||||
|
|
|
|||
|
|
@ -378,6 +378,22 @@ module JamRuby
|
|||
def self.hourly_check
|
||||
send_onboarding_surveys
|
||||
send_take_lesson_poke
|
||||
first_lesson_instructions
|
||||
end
|
||||
|
||||
def self.first_lesson_instructions
|
||||
User.came_through_amazon.joins(taken_lessons: [:music_session, :lesson_booking])
|
||||
.where('lesson_bookings.recurring = FALSE')
|
||||
.where('lesson_sessions.status = ?', LessonSession::STATUS_APPROVED)
|
||||
.where("scheduled_start - (INTERVAL '2 days') < ?", Time.now)
|
||||
.where('sent_first_lesson_instr_email_at is null')
|
||||
.where('second_onboarding_free_lesson_at is null').each do |user|
|
||||
|
||||
UserMailer.amazon_first_lesson_instructions(user).deliver_now
|
||||
User.where(id: user.id).update_all(sent_first_lesson_instr_email_at: Time.now)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def self.send_onboarding_surveys
|
||||
|
|
@ -425,8 +441,8 @@ module JamRuby
|
|||
def update_timezone(timezone)
|
||||
if timezone.nil?
|
||||
return
|
||||
|
||||
end
|
||||
|
||||
begin
|
||||
TZInfo::Timezone.get(timezone)
|
||||
User.where(id: self.id).update_all(timezone: timezone)
|
||||
|
|
@ -434,6 +450,20 @@ module JamRuby
|
|||
@@log.error("unable to find timezone=#{timezone}, e=#{e}")
|
||||
end
|
||||
end
|
||||
|
||||
def tz_safe
|
||||
tz_identifier = 'America/Chicago'
|
||||
if self.timezone
|
||||
tz_identifier = self.timezone
|
||||
end
|
||||
TZInfo::Timezone.get(tz_identifier)
|
||||
end
|
||||
|
||||
# formats at 6:30 am. input should be UTC
|
||||
def local_hour_stmt(datetime)
|
||||
tz = tz_safe
|
||||
tz.utc_to_local(datetime).strftime("%l:%M %P").strip
|
||||
end
|
||||
def has_any_free_jamtracks
|
||||
has_redeemable_jamtrack || gifted_jamtracks > 0
|
||||
end
|
||||
|
|
@ -528,6 +558,15 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
def greetings
|
||||
if anonymous?
|
||||
"Hello -"
|
||||
else
|
||||
"Hello #{first_name} -"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def location(country = false)
|
||||
loc = self.city.blank? ? '' : self.city
|
||||
loc = loc.blank? ? self.state : "#{loc}, #{self.state}" unless self.state.blank?
|
||||
|
|
|
|||
|
|
@ -521,6 +521,27 @@ describe LessonSession do
|
|||
end
|
||||
end
|
||||
|
||||
describe "upcoming_sessions_reminder_early" do
|
||||
it "succeeds" do
|
||||
lesson = normal_lesson(user, teacher)
|
||||
UserMailer.deliveries.clear
|
||||
LessonSession.upcoming_sessions_reminder_early
|
||||
#UserMailer.deliveries.count.should eql 2
|
||||
lesson.touch
|
||||
lesson.sent_early_starting_notice.should be_false
|
||||
lesson.is_approved?.should be_true
|
||||
lesson.music_session.scheduled_start = 78.minutes.from_now
|
||||
lesson.music_session.save!
|
||||
LessonSession.upcoming_sessions_reminder_early
|
||||
UserMailer.deliveries.count.should eql 2
|
||||
UserMailer.deliveries.clear
|
||||
lesson.reload
|
||||
lesson.sent_early_starting_notice.should be_true
|
||||
LessonSession.upcoming_sessions_reminder_early
|
||||
UserMailer.deliveries.count.should eql 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "remindable_onboarding_users" do
|
||||
it "works" do
|
||||
LessonSession.remindable_onboarding_users.count.should eql 0
|
||||
|
|
|
|||
|
|
@ -1018,6 +1018,56 @@ describe User do
|
|||
end
|
||||
end
|
||||
|
||||
describe "first_lesson_instructions" do
|
||||
let(:user) {FactoryGirl.create(:user)}
|
||||
before(:each) {
|
||||
UserMailer.deliveries.clear
|
||||
}
|
||||
after {
|
||||
Timecop.return
|
||||
}
|
||||
|
||||
it "works" do
|
||||
User.first_lesson_instructions
|
||||
UserMailer.deliveries.count.should eql 0
|
||||
UserMailer.deliveries.clear
|
||||
|
||||
posa_card = FactoryGirl.create(:amazon_test_drive_free_2)
|
||||
posa_card.claim(user)
|
||||
|
||||
|
||||
User.first_lesson_instructions
|
||||
UserMailer.deliveries.count.should eql 0
|
||||
UserMailer.deliveries.clear
|
||||
|
||||
|
||||
teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now)
|
||||
lesson = normal_lesson(user, teacher.user)
|
||||
UserMailer.deliveries.clear
|
||||
|
||||
lesson.status.should eql LessonSession::STATUS_APPROVED
|
||||
lesson.lesson_booking.recurring.should eql false
|
||||
user.sent_first_lesson_instr_email_at.should be_nil
|
||||
user.second_onboarding_free_lesson_at.should be_nil
|
||||
User.first_lesson_instructions
|
||||
UserMailer.deliveries.count.should eql 0
|
||||
UserMailer.deliveries.clear
|
||||
|
||||
Timecop.freeze(user.taken_lessons[0].scheduled_start - 1.day)
|
||||
|
||||
User.first_lesson_instructions
|
||||
UserMailer.deliveries.count.should eql 1
|
||||
UserMailer.deliveries.clear
|
||||
user.reload
|
||||
user.sent_first_lesson_instr_email_at.should eql Time.now
|
||||
|
||||
User.first_lesson_instructions
|
||||
UserMailer.deliveries.count.should eql 0
|
||||
UserMailer.deliveries.clear
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "send_take_lesson_poke" do
|
||||
let(:user) {FactoryGirl.create(:user)}
|
||||
before(:each) {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,13 @@ describe "RenderMailers", :slow => true do
|
|||
it { @filename="updated_email"; UserMailer.updated_email(user).deliver_now }
|
||||
it { @filename="updating_email"; UserMailer.updating_email(user).deliver_now }
|
||||
|
||||
describe "amazon_first_lesson_scheduled" do
|
||||
it {@filename="amazon_first_lesson_scheduled"; UserMailer.amazon_first_lesson_scheduled(user).deliver_now}
|
||||
end
|
||||
|
||||
describe "amazon_first_lesson_instructions" do
|
||||
it {@filename="amazon_first_lesson_instructions"; UserMailer.amazon_first_lesson_instructions(user).deliver_now}
|
||||
end
|
||||
|
||||
describe "has sending user" do
|
||||
let(:user2) { FactoryGirl.create(:user) }
|
||||
|
|
@ -156,7 +163,7 @@ describe "RenderMailers", :slow => true do
|
|||
lesson = testdrive_lesson(user, teacher)
|
||||
|
||||
UserMailer.deliveries.clear
|
||||
UserMailer.lesson_starting_soon_teacher(lesson).deliver_now
|
||||
UserMailer.lesson_starting_soon_teacher(lesson, false, '6:36 am').deliver_now
|
||||
end
|
||||
|
||||
it "lesson_starting_soon_student" do
|
||||
|
|
@ -164,7 +171,24 @@ describe "RenderMailers", :slow => true do
|
|||
lesson = testdrive_lesson(user, teacher)
|
||||
|
||||
UserMailer.deliveries.clear
|
||||
UserMailer.lesson_starting_soon_student(lesson).deliver_now
|
||||
UserMailer.lesson_starting_soon_student(lesson, false, '6:36 am').deliver_now
|
||||
end
|
||||
|
||||
|
||||
it "lesson_starting_soon_teacher_early" do
|
||||
@filename = "lesson_starting_soon_teacher_early"
|
||||
lesson = testdrive_lesson(user, teacher)
|
||||
|
||||
UserMailer.deliveries.clear
|
||||
UserMailer.lesson_starting_soon_teacher(lesson, true, '6:36 am').deliver_now
|
||||
end
|
||||
|
||||
it "lesson_starting_soon_student_early" do
|
||||
@filename = "lesson_starting_soon_student_early"
|
||||
lesson = testdrive_lesson(user, teacher)
|
||||
|
||||
UserMailer.deliveries.clear
|
||||
UserMailer.lesson_starting_soon_student(lesson, true, '6:36 am').deliver_now
|
||||
end
|
||||
|
||||
it "music_notation_attachment" do
|
||||
|
|
|
|||
Loading…
Reference in New Issue