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 0d6ba9a6b..26d7cf716 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 @@ -3,35 +3,90 @@
Hello <%= @user.first_name %> --
-The following new sessions that that have been posted during the last 24 hours: -
-The following new sessions have been posted within the last 24 hours, and you have good or acceptable latency to the organizer of each session below. If a session looks interesting, click the Details link to see the session page. You can RSVP to a session from the session page, and you'll be notified if/when the session organizer approves your RSVP.
-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! -
+ + +| GENRE | -DESCRIPTION | +GENRE | +NAME | +DESCRIPTION | LATENCY |
|---|---|---|---|---|---|
| <%= sess.genre.description %> | -<%= sess.description %> | -<%= sess.latency %> | -|||
| <%= sess.genre.description %> | +
+ <%= sess.name %> + ">Details + |
+ <%= sess.description %> | ++ + <%= sess.latency %> ms + <% if sess.latency <= APP_CONFIG.max_good_full_score %> + <%= image_tag("http://www.jamkazam.com/assets/content/icon_green_score.png", alt: 'good score icon') %> + <% else %> + <%= image_tag("http://www.jamkazam.com/assets/content/icon_yellow_score.png", alt: 'fair score icon') %> + <% end %> + + | +
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. -
+To see ALL the scheduled sessions that you might be interested in joining, view our Find Session page.
Best Regards,
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 423c57f44..9720550d5 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 @@ -2,16 +2,11 @@ Hello <%= @user.first_name %> -- -The following new sessions that that have been posted during the last 24 hours: +The following new sessions have been posted within the last 24 hours, and you have good or acceptable latency to the organizer of each session below. If a session looks interesting, click the Details link to see the session page. You can RSVP to a session from the session page, and you'll be notified if/when the session organizer approves your RSVP. -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 - -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! - -GENRE | DESCRIPTION | LATENCY +GENRE | NAME | DESCRIPTION | LATENCY <% @sessions_and_latency.each do |sess| %> -<%= sess.genre.description %> | <%= sess.description %> | <%= sess.latency %> +<%= sess.genre.description %> | <%= sess.name %> | <%= sess.description %> | <%= sess.latency %> ms <% end %> 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. diff --git a/ruby/lib/jam_ruby/app/views/layouts/from_user_mailer.html.erb b/ruby/lib/jam_ruby/app/views/layouts/from_user_mailer.html.erb index 3d03cec55..8ce59bc6b 100644 --- a/ruby/lib/jam_ruby/app/views/layouts/from_user_mailer.html.erb +++ b/ruby/lib/jam_ruby/app/views/layouts/from_user_mailer.html.erb @@ -9,7 +9,6 @@ margin-bottom:0px; line-height:140%; } - diff --git a/ruby/lib/jam_ruby/models/connection.rb b/ruby/lib/jam_ruby/models/connection.rb index 27d715238..186635bce 100644 --- a/ruby/lib/jam_ruby/models/connection.rb +++ b/ruby/lib/jam_ruby/models/connection.rb @@ -164,7 +164,7 @@ module JamRuby # if user joins the session as a musician, update their addr and location if as_musician user.update_addr_loc(self, User::JAM_REASON_JOIN) - user.update_audio_latency(self, audio_latency) + user.update_audio_latency(self, audio_latency) if audio_latency # try not to let a previously recorded value get nil'ed end end 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 9bc6a742c..144099a24 100644 --- a/ruby/lib/jam_ruby/models/email_batch_scheduled_sessions.rb +++ b/ruby/lib/jam_ruby/models/email_batch_scheduled_sessions.rb @@ -19,16 +19,43 @@ module JamRuby def persisted?; false; end end + # Temporary Tables created by this class: + + # tmp_candidate_sessions + # ---------------------- + # + # These are 'open' sessions that have any open slots left, and fall within a certain start time. + # The session creator must also have a locidispid. + # + # session_id - music_session.id + # creator_id - music_session.user_id + # creator_score_idx - this is the creator's users.last_jam_locidispid + # instrument_id - instruments that are open as gleamed from the RSVP. If this is NULL, it means 'ANY INSTRUMENT' + # + # tmp_candidate_recipients + # ------------------------ + # + # These are musicians, that allow email notifications, that have an instrument which matches the session's open RSVP slot's instrument. + # The musician must also have a locidispid. + # + # receiver_id - user ID that could be in the session + # receiver_score_idx - the user's last_jam_locidispid + # instrument_id - the user's matching instrument for a open session slot. If this is NULL, it means 'ANY INSTRUMENT' + # + # tmp_matches + # ----------- + # + # These are 'candidate_recipients' that have a decent enough score with the creator of the music sessions in tmp_candidate_sessions + # + # receiver_id - the user.id that should receive an Daily Session email + # session_id - the music_session.id for the email + # latency - the score.score between the creator and the candidate (needs to be full score soon) class EmailBatchScheduledSessions < EmailBatchPeriodic BATCH_SIZE = 500 SINCE_DAYS = 2 MIN_HOURS_START = 2 - TMP_SESS = 'tmp_candidate_sessions' - TMP_RECIP = 'tmp_candidate_recipients' - TMP_MATCH = 'tmp_matches' - ENV_MAX_LATENCY = 'env_max_latency' ENV_QUERY_LIMIT = 'env_query_limit' SNAPSHOT_QUERY_LIMIT = '500' @@ -57,18 +84,18 @@ module JamRuby end def snapshot_eligible_sessions - rr = ActiveRecord::Base.connection.execute("SELECT COUNT(*) AS num FROM #{TMP_SESS}") - [0 < rr.count ? rr[0]['num'].to_i : 0, ResultStub.stubs("SELECT * FROM #{TMP_SESS}")] + rr = ActiveRecord::Base.connection.execute("SELECT COUNT(*) AS num FROM tmp_candidate_sessions") + [0 < rr.count ? rr[0]['num'].to_i : 0, ResultStub.stubs("SELECT * FROM tmp_candidate_sessions")] end def snapshot_eligible_recipients - rr = ActiveRecord::Base.connection.execute("SELECT COUNT(*) AS num FROM #{TMP_RECIP}") - [0 < rr.count ? rr[0]['num'].to_i : 0, ResultStub.stubs("SELECT * FROM #{TMP_RECIP}")] + rr = ActiveRecord::Base.connection.execute("SELECT COUNT(*) AS num FROM tmp_candidate_recipients") + [0 < rr.count ? rr[0]['num'].to_i : 0, ResultStub.stubs("SELECT * FROM tmp_candidate_recipients")] end def snapshot_scored_recipients - rr = ActiveRecord::Base.connection.execute("SELECT COUNT(*) AS num FROM #{TMP_MATCH}") - [0 < rr.count ? rr[0]['num'].to_i : 0, ResultStub.stubs("SELECT * FROM #{TMP_MATCH}")] + rr = ActiveRecord::Base.connection.execute("SELECT COUNT(*) AS num FROM tmp_matches") + [0 < rr.count ? rr[0]['num'].to_i : 0, ResultStub.stubs("SELECT * FROM tmp_matches")] end def take_snapshot @@ -91,9 +118,9 @@ module JamRuby # now just get the sessions/latency for each distinct mail recipient _select_scored_recipients(offset).each do |result| receiver = User.find_by_id(result['receiver_id']) - sessions = MusicSession.select("music_sessions.*, #{TMP_MATCH}.latency") - .joins("INNER JOIN #{TMP_MATCH} ON #{TMP_MATCH}.session_id = music_sessions.id") - .where(["#{TMP_MATCH}.receiver_id = ?", receiver.id]) + sessions = MusicSession.select("music_sessions.*, tmp_matches.latency") + .joins("INNER JOIN tmp_matches ON tmp_matches.session_id = music_sessions.id") + .where(["tmp_matches.receiver_id = ?", receiver.id]) .includes([:genre, :creator]) block_given? ? yield(receiver, sessions) : objs << [receiver, sessions] end @@ -126,7 +153,7 @@ module JamRuby # inserts eligible sessions to temp table def _collect_eligible_sessions - ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS #{TMP_SESS}") + ActiveRecord::Base.connection.execute("DROP TABLE IF EXISTS tmp_candidate_sessions") limit_sql = (self.snapshot? && 0 < ENV[ENV_QUERY_LIMIT].to_i) ? "LIMIT #{ENV[ENV_QUERY_LIMIT]}" : '' sql =<