diff --git a/ruby/lib/jam_ruby/models/music_session_user_history.rb b/ruby/lib/jam_ruby/models/music_session_user_history.rb index 6354ac628..979a17e71 100644 --- a/ruby/lib/jam_ruby/models/music_session_user_history.rb +++ b/ruby/lib/jam_ruby/models/music_session_user_history.rb @@ -111,8 +111,9 @@ module JamRuby end def should_rate_session? - 2 <= music_session_history.unique_users.count && - 60 < (Time.now - music_session_history.created_at).seconds + (2 <= music_session_history.unique_users.all.count && + 60 < (Time.now - music_session_history.created_at).seconds) || + Rails.env.development? end end diff --git a/web/app/assets/javascripts/ga.js b/web/app/assets/javascripts/ga.js index 0b3ed3f27..a2d30f72b 100644 --- a/web/app/assets/javascripts/ga.js +++ b/web/app/assets/javascripts/ga.js @@ -293,6 +293,7 @@ GA.trackFTUECompletion = trackFTUECompletion; GA.trackSessionCount = trackSessionCount; GA.trackSessionMusicians = trackSessionMusicians; + GA.trackSessionQuality = trackSessionQuality; GA.trackServiceInvitations = trackServiceInvitations; GA.trackFindSessions = trackFindSessions; GA.virtualPageView = virtualPageView; diff --git a/web/app/assets/javascripts/rateSessionDialog.js b/web/app/assets/javascripts/rateSessionDialog.js index 16bde8cf0..f9dc49e40 100644 --- a/web/app/assets/javascripts/rateSessionDialog.js +++ b/web/app/assets/javascripts/rateSessionDialog.js @@ -3,7 +3,7 @@ "use strict"; context.JK = context.JK || {}; - context.JK.RateSessionDialog = function(app, finishedCallback) { + context.JK.RateSessionDialog = function(app) { var logger = context.JK.logger; var dialogId = 'rate-session-dialog'; var $scopeSelector = "[layout-id='rate-session-dialog']"; @@ -16,24 +16,24 @@ function showDialog() { if (context.JK.JamServer.clientID) { - // $.ajax({ - // type: "/api/participant_histories/"+context.JK.JamServer.clientID, - // url: url, - // data: { rating: getRating(), comment: getComment() } - // }).done(function (response) { - // }); - reset(); - app.layout.showDialog(dialogId); - return true; // false if should not show dialog + $.ajax({ + type: "GET", + url: "/api/participant_histories/"+context.JK.JamServer.clientID + }).done(function (response) { + if (response && + response.hasOwnProperty('should_rate_session') && + true==response['should_rate_session']) { + reset(); + app.layout.showDialog(dialogId); + } + }); + return true; } return false; } function closeDialog() { app.layout.closeDialog(dialogId); - if (finishedCallback) { - setTimeout(finishedCallback, 10); - } } function getRating() { diff --git a/web/app/assets/javascripts/session.js b/web/app/assets/javascripts/session.js index 9896f9dab..8f9da6756 100644 --- a/web/app/assets/javascripts/session.js +++ b/web/app/assets/javascripts/session.js @@ -1306,25 +1306,24 @@ } } - function sessionLeave(evt) { - evt.preventDefault(); - rateSession(); - return false; - } - function bailOut() { promptLeave = false; context.window.location = '/client#/home'; } + function sessionLeave(evt) { + evt.preventDefault(); + rateSession(); + bailOut(); + return false; + } + function rateSession() { if (rateSessionDialog === null) { - rateSessionDialog = new context.JK.RateSessionDialog(context.JK.app, bailOut); + rateSessionDialog = new context.JK.RateSessionDialog(context.JK.app); rateSessionDialog.initialize(); } - if (rateSessionDialog.showDialog() === false) { - bailOut(); - } + rateSessionDialog.showDialog(); return true; } diff --git a/web/app/controllers/api_music_sessions_controller.rb b/web/app/controllers/api_music_sessions_controller.rb index ce47df7de..adf807ac2 100644 --- a/web/app/controllers/api_music_sessions_controller.rb +++ b/web/app/controllers/api_music_sessions_controller.rb @@ -166,10 +166,9 @@ class ApiMusicSessionsController < ApiController uu.save end if uu render :json => {}, :status => :ok - - elsif request.get? - render :json => { :should_rate_session => @history.should_rate_session? }, :status => :ok end + elsif request.get? + render :json => { :should_rate_session => @history.should_rate_session? }, :status => :ok end else render :json => { :message => ValidationMessages::SESSION_NOT_FOUND }, :status => 404