From ff15da9f4e8ebe04034b51d6bc3901f1cd73266d Mon Sep 17 00:00:00 2001 From: Jonathan Kolyer Date: Thu, 29 May 2014 16:32:22 +0000 Subject: [PATCH] VRFS-1665 mail formatting; bug fixing --- ruby/lib/jam_ruby/app/mailers/user_mailer.rb | 7 +-- .../scheduled_session_daily.html.erb | 42 ++++++++++++--- .../scheduled_session_daily.text.erb | 26 +++++---- .../models/email_batch_scheduled_sessions.rb | 54 +++++++++++-------- ruby/lib/jam_ruby/models/music_session.rb | 2 + 5 files changed, 85 insertions(+), 46 deletions(-) diff --git a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb index 975e8f9a8..9b2406c0d 100644 --- a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb +++ b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb @@ -391,7 +391,7 @@ end end - def scheduled_session_daily(receiver, sessions) + def scheduled_session_daily(receiver, sessions_and_latency) sendgrid_category "Notification" sendgrid_unique_args :type => "scheduled_session_daily" @@ -399,10 +399,11 @@ sendgrid_substitute('@USERID', [receiver.id]) @user = receiver + @sessions_and_latency = sessions_and_latency + @title = 'New Scheduled Sessions Matched to You' mail(:to => receiver.email, - :subject => EmailBatchScheduledSessions.subject, - :title => 'New Scheduled Sessions Matched to You') do |format| + :subject => EmailBatchScheduledSessions.subject) do |format| format.text format.html end diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_daily.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_daily.html.erb index 4a1fc0718..40788d8de 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_daily.html.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_daily.html.erb @@ -1,10 +1,38 @@ -<% provide(:title, 'Scheduled Session RSVP') %> +<% provide(:title, @title) %> -

<%= @body %>

- -

- <%= @session_name %>
- <%= @session_date %> +

Hello <%= @user.first_name %> --

-

View Session Details

+

The following new sessions that that have been posted during the last 24 hours: +

+
    +
  1. Need someone who plays an instrument that you play
  2. +
  3. Were posted by someone to whom you have either a good or medium latency connection
  4. +
+ +

Take a look through these new sessions below, and just click the RSVP button on the far right side of the row for any session in which you'd like to play. This will let the session organizer know you're interested, and you'll be notified if the session organizer accepts your request to play in that session! +

+ + + + + + + + + +<% @sessions_and_latency.each do |sess| %> + + + + + +<% end %> +
GENREDESCRIPTIONLATENCY
<%= sess.genre.description %><%= sess.description %><%= sess.latency_store %>
+ +

To see ALL the scheduled sessions that you might be interested in joining, view our Find Session page at: http://www.jamkazam.com/client#/findSession. +

+ +

Best Regards,

+ +Team JamKazam diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_daily.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_daily.text.erb index c5515de0c..16ce1e7c1 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_daily.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/scheduled_session_daily.text.erb @@ -1,23 +1,21 @@ <% provide(:title, @title) %> -

Hello <%= @user.first_name %> -- -

+Hello <%= @user.first_name %> -- -

The following new sessions that that have been posted during the last 24 hours: -

-
    -
  1. Need someone who plays an instrument that you play
  2. -
  3. Were posted by someone to whom you have either a good or medium latency connection
  4. -
+The following new sessions that that have been posted during the last 24 hours: -

Take a look through these new sessions below, and just click the RSVP button on the far right side of the row for any session in which you'd like to play. This will let the session organizer know you're interested, and you'll be notified if the session organizer accepts your request to play in that session! -

+1. Need someone who plays an instrument that you play +2. Were posted by someone to whom you have either a good or medium latency connection -HERE WE PRESENT THE SESSIONS IN A TABLE JUST LIKE THE FIND SESSION PAGE +Take a look through these new sessions below, and just click the RSVP button on the far right side of the row for any session in which you'd like to play. This will let the session organizer know you're interested, and you'll be notified if the session organizer accepts your request to play in that session! -

To see ALL the scheduled sessions that you might be interested in joining, view our Find Session page at: http://www.jamkazam.com/client#/findSession. -

+GENRE | DESCRIPTION | LATENCY +<% @sessions_and_latency.each do |sess| %> +<%= sess.genre.description %> | <%= sess.description %> | <%= sess.latency_store %> +<% end %> -

Best Regards,

+To see ALL the scheduled sessions that you might be interested in joining, view our Find Session page at: http://www.jamkazam.com/client#/findSession. + +Best Regards, Team JamKazam diff --git a/ruby/lib/jam_ruby/models/email_batch_scheduled_sessions.rb b/ruby/lib/jam_ruby/models/email_batch_scheduled_sessions.rb index 4608ed95b..db13ea5b8 100644 --- a/ruby/lib/jam_ruby/models/email_batch_scheduled_sessions.rb +++ b/ruby/lib/jam_ruby/models/email_batch_scheduled_sessions.rb @@ -12,17 +12,18 @@ module JamRuby "New sessions have been scheduled that may be a good match for you!" end - def fetch_sessions - objs = [] - MusicSession.open_sessions - .where(['created_at > ?', time_since_last_batch(SINCE_DAYS)]) - .where(['scheduled_start >= ?', Time.now() + MIN_HOURS_START.hours]) - .find_each do |ss| - block_given? ? yield(ss) : objs << ss - end - objs - end + # def fetch_sessions + # objs = [] + # MusicSession.open_sessions + # .where(['created_at > ?', time_since_last_batch(SINCE_DAYS)]) + # .where(['scheduled_start >= ?', Time.now() + MIN_HOURS_START.hours]) + # .find_each do |ss| + # block_given? ? yield(ss) : objs << ss + # end + # objs + # end + # inserts eligible sessions to temp table def prep_tmp_table ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS #{TMP_SNAP}") sql =<