From c3461e82a747d816a3c360bee7b6f13c5f9c5b9d Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 29 Jul 2014 17:52:20 -0500 Subject: [PATCH] * VRFS-1976 - fixed issue where UI always picks 1st scheduled session; VRFS-1962 - use 'full latency' instead of just internet latency in musician search, find session, and new musicians email --- db/manifest | 3 +- ...ms_index_sms_index_use_user_instrument.sql | 163 ++++ ruby/lib/jam_ruby/models/search.rb | 23 +- .../models/active_music_session_spec.rb | 4 +- .../jam_ruby/models/music_session_spec.rb | 12 +- .../javascripts/dialog/rsvpSubmitDialog.js | 8 +- web/app/assets/javascripts/findMusician.js | 42 +- .../assets/javascripts/scheduled_session.js | 9 +- web/app/assets/javascripts/sessionList.js | 40 +- web/app/assets/javascripts/utils.js | 2 +- web/app/assets/stylesheets/client/client.css | 1 + .../assets/stylesheets/client/help.css.scss | 43 + web/app/views/api_search/index.rabl | 6 +- web/app/views/clients/_help.html.erb | 22 + web/app/views/clients/_musicians.html.erb | 2 +- .../views/clients/_scheduledSession.html.erb | 2 +- .../views/dialogs/_rsvpSubmitDialog.html.haml | 2 +- .../api_music_sessions_controller_spec.rb | 8 +- web/spec/features/create_session_flow_spec.rb | 25 + web/spec/features/create_session_spec.rb | 2 +- web/spec/requests/musician_search_api_spec.rb | 5 +- .../assets/javascripts/jquery.icheck.js | 859 +++++++++--------- 22 files changed, 804 insertions(+), 479 deletions(-) create mode 100644 db/up/current_scores_ams_index_sms_index_use_user_instrument.sql create mode 100644 web/app/assets/stylesheets/client/help.css.scss diff --git a/db/manifest b/db/manifest index e23c3243d..76f231c5a 100755 --- a/db/manifest +++ b/db/manifest @@ -197,4 +197,5 @@ update_sms_index.sql connection_allow_null_locidispid.sql track_user_in_scores.sql median_aggregate.sql -current_scores_use_median.sql \ No newline at end of file +current_scores_use_median.sql +current_scores_ams_index_sms_index_use_user_instrument.sql \ No newline at end of file diff --git a/db/up/current_scores_ams_index_sms_index_use_user_instrument.sql b/db/up/current_scores_ams_index_sms_index_use_user_instrument.sql new file mode 100644 index 000000000..a3f7b7b10 --- /dev/null +++ b/db/up/current_scores_ams_index_sms_index_use_user_instrument.sql @@ -0,0 +1,163 @@ +-- this adds the user's latency, if available + +DROP VIEW current_scores; +CREATE OR REPLACE VIEW current_scores AS + + SELECT * FROM (SELECT * , row_number() OVER (PARTITION BY alocidispid, blocidispid, scorer ORDER BY full_score DESC) AS pcnum FROM + (SELECT * FROM + (SELECT percent_rank() over (PARTITION BY alocidispid, blocidispid ORDER BY full_score ASC) AS pc, * FROM + (SELECT tmp.*, (COALESCE(a_users.last_jam_audio_latency, 13) + COALESCE(b_users.last_jam_audio_latency, 13) + tmp.score) AS full_score, a_users.last_jam_audio_latency AS a_audio_latency, b_users.last_jam_audio_latency AS b_audio_latency FROM + (SELECT *, row_number() OVER (PARTITION BY alocidispid, blocidispid ORDER BY scores.created_at DESC) AS rownum FROM scores) tmp + LEFT JOIN users as a_users ON a_users.id = tmp.auserid + LEFT JOIN users as b_users ON b_users.id = tmp.buserid + WHERE rownum < 6) AS score_ranked) + AS tmp2 WHERE pc <= .5 ORDER BY pc DESC) pcs ) + AS final WHERE pcnum < 2; + + +-- check that the music_sessions does not currently have an active_music_sessions +CREATE OR REPLACE FUNCTION sms_index (my_user_id VARCHAR, my_locidispid BIGINT, my_audio_latency INTEGER) RETURNS VOID STRICT VOLATILE AS $$ + BEGIN + -- output table to hold tagged music sessions with latency + CREATE TEMPORARY TABLE sms_music_session_tmp (music_session_id VARCHAR(64) NOT NULL, tag INTEGER, latency INTEGER) ON COMMIT DROP; + + -- populate sms_music_session_tmp as all music sessions + -- XXX: we should pass in enough info to match pagination/query to reduce the impact of this step + INSERT INTO sms_music_session_tmp SELECT DISTINCT id, NULL::INTEGER AS tag, NULL::INTEGER AS latency + FROM music_sessions + WHERE (scheduled_start IS NULL OR scheduled_start > (NOW() - (interval '15 minute'))) + AND canceled = FALSE + AND id NOT IN (SELECT id FROM active_music_sessions); + + -- tag accepted rsvp as 1 + UPDATE sms_music_session_tmp q SET tag = 1 FROM rsvp_slots s, rsvp_requests_rsvp_slots rrs, rsvp_requests r WHERE + q.music_session_id = s.music_session_id AND + s.id = rrs.rsvp_slot_id AND + rrs.rsvp_request_id = r.id AND + r.user_id = my_user_id AND + rrs.chosen = TRUE AND + q.tag is NULL; + + -- tag invitation as 2 + UPDATE sms_music_session_tmp q SET tag = 2 FROM invitations i WHERE + q.music_session_id = i.music_session_id AND + i.receiver_id = my_user_id AND + q.tag IS NULL; + + -- musician access as 3 + UPDATE sms_music_session_tmp q SET tag = 3 FROM music_sessions m WHERE + q.music_session_id = m.id AND + m.open_rsvps = TRUE AND + q.tag IS NULL; + + -- delete anything not tagged + DELETE FROM sms_music_session_tmp WHERE tag IS NULL; + + -- output table to hold users involved in the sms_music_session_tmp sessions and their latency + CREATE TEMPORARY TABLE sms_users_tmp (music_session_id VARCHAR(64), user_id VARCHAR(64) NOT NULL, latency INTEGER) ON COMMIT DROP; + + IF my_audio_latency > -1 THEN + -- populate sms_users_tmp with users that have an approved RSVP for sessions in the sms_music_session_tmp table, accompanied with full latency and music session + INSERT INTO sms_users_tmp SELECT q.music_session_id, users.id, s.full_score/2 AS latency + FROM sms_music_session_tmp q + INNER JOIN rsvp_slots ON rsvp_slots.music_session_id = q.music_session_id + INNER JOIN rsvp_requests_rsvp_slots ON rsvp_requests_rsvp_slots.rsvp_slot_id = rsvp_slots.id + INNER JOIN rsvp_requests ON rsvp_requests.id = rsvp_requests_rsvp_slots.rsvp_request_id + INNER JOIN users ON rsvp_requests.user_id = users.id + LEFT OUTER JOIN current_scores s ON s.alocidispid = users.last_jam_locidispid + WHERE + s.blocidispid = my_locidispid AND + rsvp_requests_rsvp_slots.chosen = TRUE; + + -- populate sms_users_tmp with invited users for session in the sms_music_session_tmp table, accompanied with full latency and music session + -- specify NULL for music_session_id, because we don't want RSVP users to affect the AVG computed for each session later + INSERT INTO sms_users_tmp SELECT NULL, users.id, s.full_score/2 AS latency + FROM sms_music_session_tmp q + INNER JOIN invitations ON invitations.music_session_id = q.music_session_id + INNER JOIN users ON invitations.receiver_id = users.id + LEFT OUTER JOIN current_scores s ON s.alocidispid = users.last_jam_locidispid + WHERE + s.blocidispid = my_locidispid AND + users.id NOT IN (SELECT user_id FROM sms_users_tmp); + END IF; + + -- calculate the average latency + UPDATE sms_music_session_tmp q SET latency = (select AVG(u.latency) FROM sms_users_tmp u WHERE + q.music_session_id = u.music_session_id); + + RETURN; + END; +$$ LANGUAGE plpgsql; + +-- my_audio_latency can have a special value of -1, which means 'unknown'. +CREATE OR REPLACE FUNCTION ams_index (my_user_id VARCHAR, my_locidispid BIGINT, my_audio_latency INTEGER) RETURNS VOID STRICT VOLATILE AS $$ + BEGIN + -- output table to hold tagged music sessions with latency + CREATE TEMPORARY TABLE ams_music_session_tmp (music_session_id VARCHAR(64) NOT NULL, tag INTEGER, latency INTEGER) ON COMMIT DROP; + + -- populate ams_music_session_tmp as all music sessions + INSERT INTO ams_music_session_tmp SELECT DISTINCT id, NULL::INTEGER AS tag, NULL::INTEGER AS latency + FROM active_music_sessions; + + -- TODO worry about active music session where my_user_id is the creator? + -- eh, maybe, but if the music session is active and you're the creator wouldn't you already be in it? + -- so maybe you're on another computer, so why care? plus seth is talking about auto rsvp'ing the session + -- for you, so maybe not a problem. + + -- tag accepted rsvp as 1 + UPDATE ams_music_session_tmp q SET tag = 1 FROM rsvp_slots s, rsvp_requests_rsvp_slots rrs, rsvp_requests r WHERE + q.music_session_id = s.music_session_id AND + s.id = rrs.rsvp_slot_id AND + rrs.rsvp_request_id = r.id AND + r.user_id = my_user_id AND + rrs.chosen = TRUE AND + q.tag is NULL; + + -- tag invitation as 2 + UPDATE ams_music_session_tmp q SET tag = 2 FROM invitations i WHERE + q.music_session_id = i.music_session_id AND + i.receiver_id = my_user_id AND + q.tag IS NULL; + + -- musician access as 3 + UPDATE ams_music_session_tmp q SET tag = 3 FROM music_sessions m WHERE + q.music_session_id = m.id AND + m.musician_access = TRUE AND + q.tag IS NULL; + + -- delete anything not tagged + DELETE FROM ams_music_session_tmp WHERE tag IS NULL; + + -- output table to hold users involved in the ams_music_session_tmp sessions and their latency + CREATE TEMPORARY TABLE ams_users_tmp (music_session_id VARCHAR(64), user_id VARCHAR(64) NOT NULL, latency INTEGER) ON COMMIT DROP; + + IF my_audio_latency > -1 THEN + -- populate ams_users_tmp with users that have a connection for sessions in the ams_music_session_tmp table, accompanied with full latency and music session + INSERT INTO ams_users_tmp SELECT c.music_session_id, c.user_id, s.full_score/2 AS latency + FROM ams_music_session_tmp q + INNER JOIN connections c ON c.music_session_id = q.music_session_id + LEFT OUTER JOIN current_scores s ON s.alocidispid = c.locidispid + WHERE s.blocidispid = my_locidispid; + + -- populate ams_users_tmp with users that have an approved RSVP for sessions inthe ams_music_session_tmp table, accompanied with full latency and music session + -- specify NULL for music_session_id, because we don't want RSVP users to affect the AVG computed for each session later + INSERT INTO ams_users_tmp SELECT NULL, users.id, s.full_score/2 AS latency + FROM ams_music_session_tmp q + INNER JOIN rsvp_slots ON rsvp_slots.music_session_id = q.music_session_id + INNER JOIN rsvp_requests_rsvp_slots ON rsvp_requests_rsvp_slots.rsvp_slot_id = rsvp_slots.id + INNER JOIN rsvp_requests ON rsvp_requests.id = rsvp_requests_rsvp_slots.rsvp_request_id + INNER JOIN users ON rsvp_requests.user_id = users.id + LEFT OUTER JOIN current_scores s ON s.alocidispid = users.last_jam_locidispid + WHERE + s.blocidispid = my_locidispid AND + rsvp_requests_rsvp_slots.chosen = TRUE AND + users.id NOT IN (SELECT user_id FROM ams_users_tmp); + END IF; + + -- calculate the average latency + UPDATE ams_music_session_tmp q SET latency = (select AVG(u.latency) FROM ams_users_tmp u WHERE + q.music_session_id = u.music_session_id); + + RETURN; + END; +$$ LANGUAGE plpgsql; \ No newline at end of file diff --git a/ruby/lib/jam_ruby/models/search.rb b/ruby/lib/jam_ruby/models/search.rb index 1f08651ec..761660c84 100644 --- a/ruby/lib/jam_ruby/models/search.rb +++ b/ruby/lib/jam_ruby/models/search.rb @@ -185,6 +185,7 @@ module JamRuby score_join = 'left outer' # or 'inner' score_min = nil score_max = nil + # these score_min, score_max come from here (doubled): https://jamkazam.atlassian.net/browse/VRFS-1962 case score_limit when GOOD_SCORE score_join = 'inner' @@ -193,14 +194,14 @@ module JamRuby when MODERATE_SCORE score_join = 'inner' score_min = 40 - score_max = 80 + score_max = 70 when POOR_SCORE score_join = 'inner' score_min = 80 - score_max = 120 + score_max = 100 when UNACCEPTABLE_SCORE score_join = 'inner' - score_min = 120 + score_min = 100 score_max = nil when SCORED_SCORE score_join = 'inner' @@ -221,11 +222,11 @@ module JamRuby rel = rel.joins('LEFT JOIN regions ON regions.countrycode = users.country AND regions.region = users.state') - rel = rel.where(['current_scores.score > ?', score_min]) unless score_min.nil? - rel = rel.where(['current_scores.score <= ?', score_max]) unless score_max.nil? + rel = rel.where(['current_scores.full_score > ?', score_min]) unless score_min.nil? + rel = rel.where(['current_scores.full_score <= ?', score_max]) unless score_max.nil? - rel = rel.select('current_scores.score, regions.regionname') - rel = rel.group('current_scores.score, regions.regionname') + rel = rel.select('current_scores.full_score, current_scores.score, current_scores.b_audio_latency as audio_latency, regions.regionname') + rel = rel.group('current_scores.full_score, current_scores.score, current_scores.b_audio_latency, regions.regionname') end ordering = self.order_param(params) @@ -249,7 +250,7 @@ module JamRuby end unless locidispid.nil? - rel = rel.order('current_scores.score ASC NULLS LAST') + rel = rel.order('current_scores.full_score ASC NULLS LAST') end rel = rel.order('users.created_at DESC') @@ -393,15 +394,15 @@ module JamRuby # an offline process and thus uses the last jam location as "home base" locidispid = usr.last_jam_locidispid - score_limit = 60 + score_limit = 70 limit = 50 rel = User.musicians_geocoded .where(['users.created_at >= ? AND users.id != ?', since_date, usr.id]) .joins('inner join current_scores on users.last_jam_locidispid = current_scores.alocidispid') .where(['current_scores.blocidispid = ?', locidispid]) - .where(['current_scores.score <= ?', score_limit]) - .order('current_scores.score') # best scores first + .where(['current_scores.full_score <= ?', score_limit]) + .order('current_scores.full_score') # best scores first .order('users.created_at DESC') # then most recent .limit(limit) diff --git a/ruby/spec/jam_ruby/models/active_music_session_spec.rb b/ruby/spec/jam_ruby/models/active_music_session_spec.rb index b59dd0b45..ab02b8281 100644 --- a/ruby/spec/jam_ruby/models/active_music_session_spec.rb +++ b/ruby/spec/jam_ruby/models/active_music_session_spec.rb @@ -354,8 +354,8 @@ describe ActiveMusicSession do user = FactoryGirl.create(:user, last_jam_locidispid: 1, last_jam_audio_latency: 5) c3 = FactoryGirl.create(:connection, user: user, locidispid: 1, last_jam_audio_latency: 5) - Score.createx(c1.locidispid, c1.client_id, c1.addr, c3.locidispid, c3.client_id, c3.addr, 20, nil) - Score.createx(c2.locidispid, c2.client_id, c2.addr, c3.locidispid, c3.client_id, c3.addr, 30, nil) + Score.createx(c1.locidispid, c1.client_id, c1.addr, c3.locidispid, c3.client_id, c3.addr, 20, nil, nil, {auserid: creator.id, buserid: user.id}) + Score.createx(c2.locidispid, c2.client_id, c2.addr, c3.locidispid, c3.client_id, c3.addr, 30, nil, nil, {auserid: creator2.id, buserid: user.id}) # make a transaction diff --git a/ruby/spec/jam_ruby/models/music_session_spec.rb b/ruby/spec/jam_ruby/models/music_session_spec.rb index da8692250..ad4cc67de 100644 --- a/ruby/spec/jam_ruby/models/music_session_spec.rb +++ b/ruby/spec/jam_ruby/models/music_session_spec.rb @@ -421,7 +421,7 @@ describe MusicSession do let(:network_score) { 20 } before(:each) do - Score.createx(conn.locidispid, conn.client_id, conn.addr, searcher_conn.locidispid, searcher_conn.client_id, searcher_conn.addr, network_score, nil) + Score.createx(conn.locidispid, conn.client_id, conn.addr, searcher_conn.locidispid, searcher_conn.client_id, searcher_conn.addr, network_score, nil, nil, {auserid: creator.id, buserid: searcher.id}) end it "no results" do @@ -499,7 +499,7 @@ describe MusicSession do FactoryGirl.create(:invitation, receiver:invitee, sender:creator, music_session: music_session) # create a score between invitee, and searcher - Score.createx(invitee.last_jam_locidispid, 'immaterial', 1, searcher_conn.locidispid, searcher_conn.client_id, searcher_conn.addr, network_score, nil) + Score.createx(invitee.last_jam_locidispid, 'immaterial', 1, searcher_conn.locidispid, searcher_conn.client_id, searcher_conn.addr, network_score, nil, nil, {auserid: invitee.id, buserid: searcher.id}) music_sessions, user_scores = sms(searcher, default_opts) music_sessions.length.should == 1 @@ -580,14 +580,16 @@ describe MusicSession do end it "searcher_1" do + + # create a bad score between searcher_1 and creator_1 (but we should still see it sort 1st because it's got an RSVP to the searcher) - Score.createx(searcher_conn_1.locidispid, searcher_conn_1.client_id, searcher_conn_1.addr, creator_conn_1.locidispid, creator_conn_1.client_id, creator_conn_1.addr, bad_network_score, nil) + Score.createx(searcher_conn_1.locidispid, searcher_conn_1.client_id, searcher_conn_1.addr, creator_conn_1.locidispid, creator_conn_1.client_id, creator_conn_1.addr, bad_network_score, nil, nil, {auserid: searcher_1.id, buserid: creator_1.id}) # create a fair score between searcher_1 and creator_2 (but we should still see it sort 2st because it's got an invitation to the searcher) - Score.createx(searcher_conn_1.locidispid, searcher_conn_1.client_id, searcher_conn_1.addr, creator_conn_2.locidispid, creator_conn_2.client_id, creator_conn_2.addr, fair_network_score, nil) + Score.createx(searcher_conn_1.locidispid, searcher_conn_1.client_id, searcher_conn_1.addr, creator_conn_2.locidispid, creator_conn_2.client_id, creator_conn_2.addr, fair_network_score, nil, nil, {auserid: searcher_1.id, buserid: creator_2.id}) # create a good score between searcher_1 and creator_3 (but we should still see it sort last because it's an open session; no affiliation with the searcher) - Score.createx(searcher_conn_1.locidispid, searcher_conn_1.client_id, searcher_conn_1.addr, creator_conn_3.locidispid, creator_conn_3.client_id, creator_conn_3.addr, good_network_score, nil) + Score.createx(searcher_conn_1.locidispid, searcher_conn_1.client_id, searcher_conn_1.addr, creator_conn_3.locidispid, creator_conn_3.client_id, creator_conn_3.addr, good_network_score, nil, nil, {auserid: searcher_1.id, buserid: creator_3.id}) music_sessions, user_scores = sms(searcher_1, {client_id: searcher_conn_1.client_id}) diff --git a/web/app/assets/javascripts/dialog/rsvpSubmitDialog.js b/web/app/assets/javascripts/dialog/rsvpSubmitDialog.js index 228b0077f..895927135 100644 --- a/web/app/assets/javascripts/dialog/rsvpSubmitDialog.js +++ b/web/app/assets/javascripts/dialog/rsvpSubmitDialog.js @@ -28,11 +28,15 @@ $('.schedule-recurrence', $dialog).html("Recurs " + response.recurring_mode + " on this day at this time"); } + var hasOpenSlots = response.open_slots && response.open_slots.length > 0; + + if (response['is_unstructured_rsvp?']) { - $('.rsvp-instruments', $dialog).append('Any Instrument
'); + var checkedState = hasOpenSlots ? '' : 'checked="checked"' + $('.rsvp-instruments', $dialog).append('Play Any Instrument You Like
'); } - if (response.open_slots && response.open_slots.length > 0) { + if (hasOpenSlots) { $.each(response.open_slots, function(index, val) { var instrument = val.instrument_id; diff --git a/web/app/assets/javascripts/findMusician.js b/web/app/assets/javascripts/findMusician.js index 7750d836c..ea8b9f564 100644 --- a/web/app/assets/javascripts/findMusician.js +++ b/web/app/assets/javascripts/findMusician.js @@ -89,8 +89,8 @@ // these are raw scores as reported by client (round trip times) if (score == null) return "purple"; if (0 < score && score <= 40) return "green"; - if (40 < score && score <= 80) return "yellow"; - if (80 < score && score <= 120) return "red"; + if (40 < score && score <= 70) return "yellow"; + if (70 < score && score <= 100) return "red"; return "blue"; } @@ -98,8 +98,8 @@ // these are raw scores as reported by client (round trip times) if (score == null) return "missing"; if (0 < score && score <= 40) return "good"; - if (40 < score && score <= 80) return "moderate"; - if (80 < score && score <= 120) return "poor"; + if (40 < score && score <= 70) return "moderate"; + if (70 < score && score <= 100) return "poor"; return "unacceptable"; } @@ -126,6 +126,7 @@ var mVals, musician, renderings=''; var instr_logos, instr; var follows, followVals, aFollow; + var myAudioLatency = musicianList.my_audio_latency; for (ii=0, len=musicians.length; ii < len; ii++) { musician = musicians[ii]; @@ -165,7 +166,7 @@ }; var musician_actions = context.JK.fillTemplate(aTemplate, actionVals); - var joined_score = musician['joined_score'] + var full_score = musician['full_score']; mVals = { avatar_url: context.JK.resolveAvatarUrl(musician.photo_url), profile_url: "/client#/profile/" + musician.id, @@ -180,22 +181,27 @@ musician_id: musician['id'], musician_follow_template: follows, musician_action_template: musician_actions, - musician_one_way_score: score_to_text(joined_score), - musician_score_color: score_to_color(joined_score), - musician_score_color_alt: score_to_color_alt(joined_score) + musician_one_way_score: score_to_text(full_score), + musician_score_color: score_to_color(full_score), + musician_score_color_alt: score_to_color_alt(full_score) + }; - var musician_row = context.JK.fillTemplate(mTemplate, mVals); - renderings += musician_row; + var $rendering = $(context.JK.fillTemplate(mTemplate, mVals)) + + var $offsetParent = $results.closest('.content'); + var options = {positions: ['top', 'bottom', 'right', 'left'], offsetParent: $offsetParent}; + var scoreOptions = {positions: ['right', 'top', 'bottom', 'left'], offsetParent: $offsetParent, width:'600px'}; + context.JK.helpBubble($('.follower-count', $rendering), 'musician-follower-count', {}, options); + context.JK.helpBubble($('.friend-count', $rendering), 'musician-friend-count', {}, options); + context.JK.helpBubble($('.recording-count', $rendering), 'musician-recording-count', {}, options); + context.JK.helpBubble($('.session-count', $rendering), 'musician-session-count', {}, options); + context.JK.helpBubble($('.score-count', $rendering), 'musician-score-count', + {full_score: full_score ? Math.round(full_score / 2) : null, my_gear_latency: myAudioLatency, their_gear_latency:musician['audio_latency'], internet_latency: musician['score']}, + scoreOptions) + + $results.append($rendering); } - var $renderings = $(renderings); - var $offsetParent = $results.closest('.content'); - var options = {positions: ['top', 'bottom', 'right', 'left'], offsetParent: $offsetParent} - context.JK.helpBubble($('.follower-count', $renderings), 'musician-follower-count', {}, options); - context.JK.helpBubble($('.friend-count', $renderings), 'musician-friend-count', {}, options); - context.JK.helpBubble($('.recording-count', $renderings), 'musician-recording-count', {}, options); - context.JK.helpBubble($('.session-count', $renderings), 'musician-session-count', {}, options); - $results.append($renderings); $('.search-m-friend').on('click', friendMusician); $('.search-m-follow').on('click', followMusician); diff --git a/web/app/assets/javascripts/scheduled_session.js b/web/app/assets/javascripts/scheduled_session.js index 63c9713b4..7b7de7843 100644 --- a/web/app/assets/javascripts/scheduled_session.js +++ b/web/app/assets/javascripts/scheduled_session.js @@ -117,14 +117,14 @@ var firstSession = function() { var $firstSession = $scheduledSessions.children().first().find('input[name="scheduled-session-info"]'); $firstSession.attr('checked', 'checked'); - createSessionSettings.selectedSessionId = $firstSession.attr('id'); + createSessionSettings.selectedSessionId = $firstSession.attr('data-session-id'); }; if (createSessionSettings.selectedSessionId == null) { firstSession(); } else { - var $selectedSession = $scheduledSessions.children().first().find('input[name="scheduled-session-info"][id="' + createSessionSettings.selectedSessionId + '"]'); + var $selectedSession = $scheduledSessions.children().first().find('input[name="scheduled-session-info"][data-session-id="' + createSessionSettings.selectedSessionId + '"]'); if ($selectedSession.length) $selectedSession.attr('checked', 'checked'); else @@ -349,6 +349,7 @@ function beforeMoveStep1() { if (createSessionSettings.createType == 'start-scheduled') { + createSessionSettings.selectedSessionId = $scheduledSessions.find('.iradio_minimal.checked input[name="scheduled-session-info"]').attr('data-session-id'); var session = scheduledSessions[createSessionSettings.selectedSessionId]; if(session == null) { @@ -382,7 +383,7 @@ var startTime = new Date(session.scheduled_start); var diffTime = startTime.getTime() - currentTime.getTime(); if (diffTime > ONE_HOUR) { - var confirmDialog = new context.JK.ConfirmDialog(app, "Start Session Now", + var confirmDialog = new context.JK.ConfirmDialog(app, "START SESSION NOW", "You are starting a session that is scheduled to begin more than one hour from now. Are you sure you want to do this?", "Future Session", moveToFinish); confirmDialog.initialize(); @@ -416,7 +417,7 @@ createSessionSettings.startTime = $startTimeList.val(); createSessionSettings.endTime = $endTimeList.val(); createSessionSettings.notations = []; - createSessionSettings.selectedSessionId = $scheduledSessions.find('input[name="scheduled-session-info"][checked="checked"]').attr('id'); + createSessionSettings.selectedSessionId = $scheduledSessions.find('.iradio_minimal.checked input[name="scheduled-session-info"]').attr('data-session-id'); createSessionSettings.timezone.value = $timezoneList.val(); createSessionSettings.timezone.label = $timezoneList.get(0).options[$timezoneList.get(0).selectedIndex].text; createSessionSettings.recurring_mode.label = $recurringModeList.get(0).options[$recurringModeList.get(0).selectedIndex].text; diff --git a/web/app/assets/javascripts/sessionList.js b/web/app/assets/javascripts/sessionList.js index b471e5a1f..4321cc183 100644 --- a/web/app/assets/javascripts/sessionList.js +++ b/web/app/assets/javascripts/sessionList.js @@ -21,9 +21,9 @@ var LATENCY = { GOOD : {description: "GOOD", style: "latency-green", min: 0.0, max: 20.0}, - MEDIUM : {description: "MEDIUM", style: "latency-yellow", min: 20.0, max: 40.0}, - POOR : {description: "POOR", style: "latency-red", min: 40.0, max: 10000000000.0}, - UNREACHABLE: {description: "UNREACHABLE", style: "latency-grey", min: -1, max: -1}, + MEDIUM : {description: "MEDIUM", style: "latency-yellow", min: 20.0, max: 35.0}, + POOR : {description: "POOR", style: "latency-red", min: 35.0, max: 50}, + UNACCEPTABLE: {description: "UNACCEPTABLE", style: "latency-grey", min: 50, max: 10000000}, UNKNOWN: {description: "UNKNOWN", style: "latency-grey", min: -2, max: -2} }; @@ -350,7 +350,10 @@ } function createLatency(user) { - var latencyStyle = LATENCY.UNREACHABLE.style, latencyDescription = LATENCY.UNREACHABLE.description + + var latencyStyle; + var latencyDescription; + if (user.id === context.JK.currentUserId) { latencyStyle = LATENCY.GOOD.style, latencyDescription = LATENCY.GOOD.description; } @@ -358,24 +361,25 @@ else { var latency = user.latency; - if (!latency || latency === 1000) { - // 1000 is a magical number returned by new scoring API to indicate one or more people in the session have an unknown score + if (!latency) { latencyDescription = LATENCY.UNKNOWN.description; latencyStyle = LATENCY.UNKNOWN.style; } + else if (latency <= LATENCY.GOOD.max) { + latencyDescription = LATENCY.GOOD.description; + latencyStyle = LATENCY.GOOD.style; + } + else if (latency > LATENCY.MEDIUM.min && latency <= LATENCY.MEDIUM.max) { + latencyDescription = LATENCY.MEDIUM.description; + latencyStyle = LATENCY.MEDIUM.style; + } + else if (latency > LATENCY.POOR.min && latency <= LATENCY.UNACCEPTABLE.max) { + latencyDescription = LATENCY.POOR.description; + latencyStyle = LATENCY.POOR.style; + } else { - if (latency <= LATENCY.GOOD.max) { - latencyDescription = LATENCY.GOOD.description; - latencyStyle = LATENCY.GOOD.style; - } - else if (latency > LATENCY.MEDIUM.min && latency <= LATENCY.MEDIUM.max) { - latencyDescription = LATENCY.MEDIUM.description; - latencyStyle = LATENCY.MEDIUM.style; - } - else { - latencyDescription = LATENCY.POOR.description; - latencyStyle = LATENCY.POOR.style; - } + latencyStyle = LATENCY.UNREACHABLE.style + latencyDescription = LATENCY.UNREACHABLE.description } } diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js index 3270cc59e..38785e099 100644 --- a/web/app/assets/javascripts/utils.js +++ b/web/app/assets/javascripts/utils.js @@ -185,7 +185,7 @@ cornerRadius: 0, cssStyles: { fontSize: '11px', - color: 'white', + color: '#cccccc', whiteSpace: 'normal' } }; diff --git a/web/app/assets/stylesheets/client/client.css b/web/app/assets/stylesheets/client/client.css index d6325a7c0..68b4073ce 100644 --- a/web/app/assets/stylesheets/client/client.css +++ b/web/app/assets/stylesheets/client/client.css @@ -53,6 +53,7 @@ *= require ./searchResults *= require ./clientUpdate *= require ./musician + *= require ./help *= require ./jquery-ui-overrides *= require web/audioWidgets *= require web/recordings diff --git a/web/app/assets/stylesheets/client/help.css.scss b/web/app/assets/stylesheets/client/help.css.scss new file mode 100644 index 000000000..691bc7c74 --- /dev/null +++ b/web/app/assets/stylesheets/client/help.css.scss @@ -0,0 +1,43 @@ +.screen { + .bt-wrapper { + .bt-content { + + color:#cccccc; + + font-size:14px; + + p { + font-size:14px; + } + ul { + font-size:14px; + } + + li { + margin-left:1em; + margin-bottom:.5em; + } + + .definition { + font-weight:bold; + } + + .help-musician-score-count { + .measurement { + + } + + .measurement-value { + font-size:24px; + } + + .measurement-absent { + font-style:italic; + font-size:12px; + display:block; + } + } + + } + } +} \ No newline at end of file diff --git a/web/app/views/api_search/index.rabl b/web/app/views/api_search/index.rabl index 5c1f8b002..e7120fca6 100644 --- a/web/app/views/api_search/index.rabl +++ b/web/app/views/api_search/index.rabl @@ -41,9 +41,13 @@ if @search.musicians_filter_search? node :page_count do |foo| @search.page_count end + + node :my_audio_latency do |user| + current_user.last_jam_audio_latency + end child(:results => :musicians) { - attributes :id, :first_name, :last_name, :name, :city, :state, :country, :email, :online, :musician, :photo_url, :biography, :joined_score, :regionname + attributes :id, :first_name, :last_name, :name, :city, :state, :country, :email, :online, :musician, :photo_url, :biography, :regionname, :score, :full_score, :audio_latency node :is_friend do |musician| @search.is_friend?(musician) diff --git a/web/app/views/clients/_help.html.erb b/web/app/views/clients/_help.html.erb index a476f3e24..1a531a89b 100644 --- a/web/app/views/clients/_help.html.erb +++ b/web/app/views/clients/_help.html.erb @@ -56,4 +56,26 @@ + + \ No newline at end of file diff --git a/web/app/views/clients/_musicians.html.erb b/web/app/views/clients/_musicians.html.erb index bbb81888e..df1b044b4 100644 --- a/web/app/views/clients/_musicians.html.erb +++ b/web/app/views/clients/_musicians.html.erb @@ -23,7 +23,7 @@ <% end -%> -