From 8f09bdce5b9b5df4620821fac6cae12116a71c0e Mon Sep 17 00:00:00 2001 From: Nuwan Chathuranga Date: Sun, 23 May 2021 18:26:21 +0530 Subject: [PATCH 01/12] musician latency badge wip --- web/app/assets/javascripts/jam_rest.js | 14 ++++++++ .../actions/LatencyActions.js.coffee | 6 ++++ .../stores/LatencyStore.js.coffee | 35 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 web/app/assets/javascripts/react-components/actions/LatencyActions.js.coffee create mode 100644 web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 99c357923..a1094a440 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -1773,6 +1773,19 @@ }); } + function getLatencyToUsers(options) { + var id = getId(options); + var user_ids = options['user_ids']; + var data = { user_ids: user_ids }; + return $.ajax({ + type: "GET", + url: '/api/users/' + id + '/latencies', + dataType: "json", + contentType: 'application/json', + data: JSON.stringify(options) + }); + } + function updateAudioLatency(options) { var id = getId(options); return $.ajax({ @@ -3204,6 +3217,7 @@ this.cancelSubscription= cancelSubscription; this.listInvoices = listInvoices; this.getVideoConferencingRoomUrl = getVideoConferencingRoomUrl; + this.getLatencyToUsers = getLatencyToUsers; return this; }; })(window, jQuery); diff --git a/web/app/assets/javascripts/react-components/actions/LatencyActions.js.coffee b/web/app/assets/javascripts/react-components/actions/LatencyActions.js.coffee new file mode 100644 index 000000000..960e236bc --- /dev/null +++ b/web/app/assets/javascripts/react-components/actions/LatencyActions.js.coffee @@ -0,0 +1,6 @@ +context = window + +@LatencyActions = Reflux.createActions({ + resolve: {} +}) + diff --git a/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee b/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee new file mode 100644 index 000000000..e019261a3 --- /dev/null +++ b/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee @@ -0,0 +1,35 @@ +$ = jQuery +context = window +logger = context.JK.logger +rest = new context.JK.Rest() + +@LatencyStore = Reflux.createStore( + { + latencies: [] + + listenables: @LatencyActions + + init: -> + this.listenTo(context.AppStore, this.onAppInit) + + onAppInit: (@app) -> + logger.debug("LatencyStore.onAppInit") + + changed: () -> + @trigger(@latencies) + + onResolve: (user_ids) -> + rest.getLatencyToUsers(user_ids).done((response) => @onLoaded(response)).fail((jqXHR) => @onUserFail(jqXHR)) + + onLoaded: (response) -> + logger.debug("LatencyStore.onLoaded", response); + @latencies.push([{ user_id: '12345', score: 5 }]) + + onUserFail:(jqXHR) -> + logger.debug("LatencyStore.onFail", jqXHR); + #@app.layout.notify({title: 'Unable to Update User Info', text: "We recommend you refresh the page."}) + + getState:() -> + { latencies: @latencies } + } +) From bcbd36a221356777f40150fd828a84a3ab1999c3 Mon Sep 17 00:00:00 2001 From: Nuwan Chathuranga Date: Wed, 26 May 2021 00:54:53 +0530 Subject: [PATCH 02/12] showing latency badge wip --- web/app/assets/javascripts/hoverMusician.js | 34 ++++++++++++++++++- web/app/assets/javascripts/jam_rest.js | 5 ++- .../stores/LatencyStore.js.coffee | 13 +++---- web/app/controllers/api_users_controller.rb | 33 +++++++++++++----- web/app/views/clients/_hoverMusician.html.erb | 3 +- 5 files changed, 69 insertions(+), 19 deletions(-) diff --git a/web/app/assets/javascripts/hoverMusician.js b/web/app/assets/javascripts/hoverMusician.js index c8b927cee..eff5a8713 100644 --- a/web/app/assets/javascripts/hoverMusician.js +++ b/web/app/assets/javascripts/hoverMusician.js @@ -7,6 +7,7 @@ var logger = context.JK.logger; var rest = context.JK.Rest(); var hoverSelector = "#musician-hover"; + var latencyBadgeSelector = '#musician-latency-badge'; var $templateLatency = null; var sessionUtils = context.JK.SessionUtils; @@ -130,6 +131,9 @@ $(hoverSelector).css(css); $(hoverSelector).fadeIn(500); + + bindUserLatencyUpdate(userId); + LatencyActions.resolve([userId]) }) .fail(function(xhr) { if(xhr.status >= 500) { @@ -180,8 +184,36 @@ } + function bindUserLatencyUpdate(userId){ + var latency; + $(document).one('user_latency_update', function(e, latencyData){ + logger.debug("bindUserLatencyUpdate", latencyData) + //latency = latencyData[0] + latency = latencyData + if(latency['id'] === userId){ + showLatencyBadge(latency) + } + }); + } + + function showLatencyBadge(latency){ + $templateLatency = $("#template-account-session-latency"); + var latencyBadge = context._.template( + $templateLatency.html(), + $.extend(latency, sessionUtils.createLatency(latency)), + { variable: 'data' } + ); + //logger.debug('BADGE', latencyBadge) + $(latencyBadgeSelector).html(latencyBadge) + } + + function unbindUserLatencyUpdate(){ + $(document).off('user_latency_update'); + } + this.hideBubble = function() { - $(hoverSelector).hide(); + unbindUserLatencyUpdate(); + $(hoverSelector).hide(); }; this.id = function() { diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index a1094a440..8ffef1c61 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -1775,14 +1775,13 @@ function getLatencyToUsers(options) { var id = getId(options); - var user_ids = options['user_ids']; - var data = { user_ids: user_ids }; + logger.debug(">>> getLatencyToUsers", options) return $.ajax({ type: "GET", url: '/api/users/' + id + '/latencies', dataType: "json", contentType: 'application/json', - data: JSON.stringify(options) + data: options }); } diff --git a/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee b/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee index e019261a3..b42563e02 100644 --- a/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee @@ -13,22 +13,23 @@ rest = new context.JK.Rest() this.listenTo(context.AppStore, this.onAppInit) onAppInit: (@app) -> - logger.debug("LatencyStore.onAppInit") changed: () -> + $(document).trigger("user_latency_update", @latencies) @trigger(@latencies) onResolve: (user_ids) -> - rest.getLatencyToUsers(user_ids).done((response) => @onLoaded(response)).fail((jqXHR) => @onUserFail(jqXHR)) - + # rest.getLatencyToUsers({user_ids: user_ids}).done((response) => @onLoaded(response)).fail((jqXHR) => @onUserFail(jqXHR)) + @latencies.push({ id: '6337dc99-5023-477f-8781-3a810bb35b61', audio_latency: 3, full_score: 5, internet_score:2 }) + @changed() + onLoaded: (response) -> logger.debug("LatencyStore.onLoaded", response); - @latencies.push([{ user_id: '12345', score: 5 }]) + @latencies.push(response) onUserFail:(jqXHR) -> logger.debug("LatencyStore.onFail", jqXHR); - #@app.layout.notify({title: 'Unable to Update User Info', text: "We recommend you refresh the page."}) - + getState:() -> { latencies: @latencies } } diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 2e78eb826..c5b9afb5a 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -937,15 +937,32 @@ class ApiUsersController < ApiController #fetch latency information from latency-graph serverless def get_latencies - query_str = params[:user_ids].split(',').inject(""){|q, id| q.concat("id=#{id}&")} - latency_url = "#{Rails.application.config.latency_data_host}/dev/user_latencies/#{current_user.id}?#{query_str}" - url = URI(latency_url) + + user_ids = params[:user_ids] + #query_str = user_ids.inject(""){|q, id| q.concat("id=#{id}&")} + #latency_url = "#{Rails.application.config.latency_data_host}/dev/user_latencies/#{current_user.id}?#{query_str}" + latency_url = "#{Rails.application.config.latency_data_host}/dev/user_latencies" + uri = URI(latency_url) begin - http = Net::HTTP.new(url.host, url.port) + header = { + 'Content-Type': 'text/json', + 'Authorization': "Basic #{Rails.application.config.latency_data_host_auth_code}" + } + http = Net::HTTP.new(uri.host, uri.port, read_timeout: 5, open_timeout: 5) http.use_ssl = true if Rails.application.config.latency_data_host.start_with?("https://") - request = Net::HTTP::Get.new(url) - request["Authorization"] = "Basic #{Rails.application.config.latency_data_host_auth_code}" - response = http.request(request) + req = Net::HTTP::Post.new(uri.path, header) + req["Authorization"] = "Basic #{Rails.application.config.latency_data_host_auth_code}" + data = { + my_user_id: current_user.id, + my_public_ip: request.remote_ip, + my_device_id: "unknown", + my_client_id: "unknown", + users: user_ids + } + req.body = data.to_json + + response = http.request(req) + if response.is_a?(Net::HTTPOK) || response.is_a?(Net::HTTPSuccess) render json: response.body, status: 200 else @@ -962,7 +979,7 @@ class ApiUsersController < ApiController render json: {}, status: 422 end rescue - Bugsnag.notify("Latency server returned code: #{response.code}") + Bugsnag.notify("Latency server returned code: #{response.code}") if response render json: {}, status: 500 end end diff --git a/web/app/views/clients/_hoverMusician.html.erb b/web/app/views/clients/_hoverMusician.html.erb index bc88742b8..39b8277c5 100644 --- a/web/app/views/clients/_hoverMusician.html.erb +++ b/web/app/views/clients/_hoverMusician.html.erb @@ -117,7 +117,8 @@
{biography}

- Your latency to {first_name} is:  {latency_badge} + Your latency to {first_name} is:   + {latency_badge}


From 5144309ff47ba1573bd6dad6f06eeb3b772bd865 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Thu, 27 May 2021 04:59:34 +0530 Subject: [PATCH 03/12] show latency badge on musician hover bubble show latency score badge by querying resolve latency api --- web/app/assets/javascripts/hoverMusician.js | 54 ++++++++++++++----- web/app/assets/javascripts/jam_rest.js | 1 - .../actions/LatencyActions.js.coffee | 1 + .../stores/LatencyStore.js.coffee | 21 ++++---- web/app/assets/javascripts/session_utils.js | 22 +++++++- web/app/assets/stylesheets/client/common.scss | 1 + .../stylesheets/client/hoverBubble.scss | 4 ++ .../assets/stylesheets/client/musician.scss | 4 ++ .../stylesheets/client/sessionList.scss | 10 ++++ .../assets/stylesheets/web/session_info.scss | 4 ++ web/app/controllers/api_users_controller.rb | 43 ++++++++------- web/app/views/clients/_hoverMusician.html.erb | 2 +- 12 files changed, 122 insertions(+), 45 deletions(-) diff --git a/web/app/assets/javascripts/hoverMusician.js b/web/app/assets/javascripts/hoverMusician.js index eff5a8713..4975a7169 100644 --- a/web/app/assets/javascripts/hoverMusician.js +++ b/web/app/assets/javascripts/hoverMusician.js @@ -92,11 +92,11 @@ full_score: fullScore }); - var latencyBadge = context._.template( - $templateLatency.html(), - $.extend(response, sessionUtils.createLatency(response)), - {variable: 'data'} - ); + // var latencyBadge = context._.template( + // $templateLatency.html(), + // $.extend(response, sessionUtils.createLatency(response)), + // {variable: 'data'} + // ); var musicianHtml = context.JK.fillTemplate(template, { userId: response.id, @@ -113,7 +113,7 @@ session_display: sessionDisplayStyle, join_display: joinDisplayStyle, sessionId: sessionId, - latency_badge: latencyBadge, + // latency_badge: latencyBadge, //friendAction: response.is_friend ? "removeMusicianFriend" : (response.pending_friend_request ? "" : "sendMusicianFriendRequest"), friendAction: response.is_friend ? "" : (response.pending_friend_request ? "" : "sendMusicianFriendRequest"), followAction: response.is_following ? "removeMusicianFollowing" : "addMusicianFollowing", @@ -133,7 +133,9 @@ $(hoverSelector).fadeIn(500); bindUserLatencyUpdate(userId); - LatencyActions.resolve([userId]) + LatencyActions.resolve([userId]); + + bindUserLatencyFail(); }) .fail(function(xhr) { if(xhr.status >= 500) { @@ -186,33 +188,57 @@ function bindUserLatencyUpdate(userId){ var latency; - $(document).one('user_latency_update', function(e, latencyData){ - logger.debug("bindUserLatencyUpdate", latencyData) - //latency = latencyData[0] - latency = latencyData - if(latency['id'] === userId){ + $(document).one('user_latency_update', function(e, latencyResp){ + latency = latencyResp['users'][0]; + //logger.debug("bindUserLatencyUpdate", latency) + if(latency['user_id'] === userId){ showLatencyBadge(latency) } }); } + function bindUserLatencyFail(){ + $(document).one('user_latency_fail', function(e, failedUserIds){ + if(_.contains(failedUserIds, userId) || failedUserIds === userId){ + showFailedLatencyBadge(userId) + } + }); + } + function showLatencyBadge(latency){ + var latencyData = sessionUtils.changeLatencyDataStructure(latency); $templateLatency = $("#template-account-session-latency"); var latencyBadge = context._.template( $templateLatency.html(), - $.extend(latency, sessionUtils.createLatency(latency)), + $.extend(latencyData, sessionUtils.createLatency(latencyData)), { variable: 'data' } ); - //logger.debug('BADGE', latencyBadge) $(latencyBadgeSelector).html(latencyBadge) } + + function showFailedLatencyBadge(userId){ + var failedLatency = { + "user_id": userId, + "audio_latency": 0, + "ars": { + "internet_latency": 0, + "total_latency": -3 + } + }; + showLatencyBadge(failedLatency); + } function unbindUserLatencyUpdate(){ $(document).off('user_latency_update'); } + function unbindUserLatencyFail(){ + $(document).off('user_latency_fail'); + } + this.hideBubble = function() { unbindUserLatencyUpdate(); + unbindUserLatencyFail(); $(hoverSelector).hide(); }; diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 8ffef1c61..7769e664b 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -1775,7 +1775,6 @@ function getLatencyToUsers(options) { var id = getId(options); - logger.debug(">>> getLatencyToUsers", options) return $.ajax({ type: "GET", url: '/api/users/' + id + '/latencies', diff --git a/web/app/assets/javascripts/react-components/actions/LatencyActions.js.coffee b/web/app/assets/javascripts/react-components/actions/LatencyActions.js.coffee index 960e236bc..2e77f316c 100644 --- a/web/app/assets/javascripts/react-components/actions/LatencyActions.js.coffee +++ b/web/app/assets/javascripts/react-components/actions/LatencyActions.js.coffee @@ -2,5 +2,6 @@ context = window @LatencyActions = Reflux.createActions({ resolve: {} + fail: {} }) diff --git a/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee b/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee index b42563e02..d5e6793fa 100644 --- a/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee @@ -15,21 +15,24 @@ rest = new context.JK.Rest() onAppInit: (@app) -> changed: () -> - $(document).trigger("user_latency_update", @latencies) + $(document).triggerHandler("user_latency_update", @latencies) @trigger(@latencies) onResolve: (user_ids) -> - # rest.getLatencyToUsers({user_ids: user_ids}).done((response) => @onLoaded(response)).fail((jqXHR) => @onUserFail(jqXHR)) - @latencies.push({ id: '6337dc99-5023-477f-8781-3a810bb35b61', audio_latency: 3, full_score: 5, internet_score:2 }) + rest.getLatencyToUsers({user_ids: user_ids}).done((response) => @onLoaded(response)).fail((jqXHR) => @onLatencyFail(jqXHR, user_ids)) + + onLoaded: (response) -> + #logger.debug("LatencyStore.onLoaded", response); + @latencies.push(response) @changed() - onLoaded: (response) -> - logger.debug("LatencyStore.onLoaded", response); - @latencies.push(response) + onLatencyFail:(jqXHR, user_ids) -> + LatencyActions.fail(user_ids) + + onFail:(user_ids) -> + $(document).triggerHandler("user_latency_fail", user_ids) + @trigger(user_ids) - onUserFail:(jqXHR) -> - logger.debug("LatencyStore.onFail", jqXHR); - getState:() -> { latencies: @latencies } } diff --git a/web/app/assets/javascripts/session_utils.js b/web/app/assets/javascripts/session_utils.js index 6daf85904..fcef0cec5 100644 --- a/web/app/assets/javascripts/session_utils.js +++ b/web/app/assets/javascripts/session_utils.js @@ -18,7 +18,8 @@ MEDIUM : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0}, POOR : {description: "POOR", style: "latency-poor", min: 70.0, max: 100}, UNACCEPTABLE: {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100, max: 10000000}, - UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2} + UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2}, + FAILED: {description: "FAILED", style: "latency-failed", min: -3, max: -3} }; sessionUtils.setAutoOpenJamTrack = function(jamTrack) { @@ -78,6 +79,16 @@ } } + sessionUtils.changeLatencyDataStructure = function(data) { + var alteredData = { + id: data.user_id, + audio_latency: data.audio_latency, + full_score: data.ars['total_latency'], + internet_score: data.ars['internet_latency'] + } + return alteredData; + } + sessionUtils.scoreInfo = function(full_score, isSameUser) { var latencyDescription; var latencyStyle; @@ -96,6 +107,12 @@ iconName = 'purple'; description = 'missing'; } + else if (full_score <= LATENCY.FAILED.max) { + latencyDescription = LATENCY.FAILED.description; + latencyStyle = LATENCY.FAILED.style; + iconName = 'gray'; + description = 'failed'; + } else if (full_score <= LATENCY.GOOD.max) { latencyDescription = LATENCY.GOOD.description; latencyStyle = LATENCY.GOOD.style; @@ -120,7 +137,7 @@ iconName = 'blue'; description = 'unacceptable'; } - + return { latency_style: latencyStyle, latency_text: latencyDescription, @@ -128,6 +145,7 @@ description: description }; } + sessionUtils.createLatency = function(user) { return sessionUtils.scoreInfo(user.full_score, user.id === context.JK.currentUserId) } diff --git a/web/app/assets/stylesheets/client/common.scss b/web/app/assets/stylesheets/client/common.scss index 5f748b06d..d238498cf 100644 --- a/web/app/assets/stylesheets/client/common.scss +++ b/web/app/assets/stylesheets/client/common.scss @@ -48,6 +48,7 @@ $latencyBadgeFair: #cc9900; $latencyBadgePoor: #980006; $latencyBadgeUnacceptable: #868686; $latencyBadgeUnknown: #868686; +$latencyBadgeFailed: #868686; $good: #71a43b; $unknown: #868686; diff --git a/web/app/assets/stylesheets/client/hoverBubble.scss b/web/app/assets/stylesheets/client/hoverBubble.scss index fda3967c9..407760f1c 100644 --- a/web/app/assets/stylesheets/client/hoverBubble.scss +++ b/web/app/assets/stylesheets/client/hoverBubble.scss @@ -120,4 +120,8 @@ .latency-poor { background-color:$latencyBadgePoor; } + + .latency-failed { + background-color:$latencyBadgeFailed; + } } \ No newline at end of file diff --git a/web/app/assets/stylesheets/client/musician.scss b/web/app/assets/stylesheets/client/musician.scss index 11c534e90..66ff4ecb8 100644 --- a/web/app/assets/stylesheets/client/musician.scss +++ b/web/app/assets/stylesheets/client/musician.scss @@ -129,6 +129,10 @@ background-color:$latencyBadgePoor; } + .latency-failed { + background-color:$latencyBadgeFailed; + } + /** .latency { font-size: 15px; diff --git a/web/app/assets/stylesheets/client/sessionList.scss b/web/app/assets/stylesheets/client/sessionList.scss index c39ee2fcd..c5df7a844 100644 --- a/web/app/assets/stylesheets/client/sessionList.scss +++ b/web/app/assets/stylesheets/client/sessionList.scss @@ -63,6 +63,16 @@ table.findsession-table, table.local-recordings, table.open-jam-tracks, table.op background-color:$latencyBadgePoor; text-align:center; } + + .latency-failed{ + width: 40px; + height: 10px; + font-family:Arial, Helvetica, sans-serif; + font-weight:200; + font-size:11px; + background-color:$latencyBadgeFailed; + text-align:center; + } } table.findsession-table, table.local-recordings, table.open-jam-tracks, table.open-backing-tracks, table.cart-items, table.payment-table, table.jamtable { width:98%; diff --git a/web/app/assets/stylesheets/web/session_info.scss b/web/app/assets/stylesheets/web/session_info.scss index 975d9db0c..e3bc7ef52 100644 --- a/web/app/assets/stylesheets/web/session_info.scss +++ b/web/app/assets/stylesheets/web/session_info.scss @@ -43,6 +43,10 @@ body.web.session_info { background-color:$latencyBadgePoor; } + .latency-failed { + background-color:$latencyBadgeFailed; + } + .latency-me { width: 40px; height: 10px; diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index c5b9afb5a..7ffd1eaa2 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -944,42 +944,49 @@ class ApiUsersController < ApiController latency_url = "#{Rails.application.config.latency_data_host}/dev/user_latencies" uri = URI(latency_url) begin - header = { - 'Content-Type': 'text/json', - 'Authorization': "Basic #{Rails.application.config.latency_data_host_auth_code}" - } - http = Net::HTTP.new(uri.host, uri.port, read_timeout: 5, open_timeout: 5) + http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if Rails.application.config.latency_data_host.start_with?("https://") - req = Net::HTTP::Post.new(uri.path, header) + req = Net::HTTP::Post.new(uri) req["Authorization"] = "Basic #{Rails.application.config.latency_data_host_auth_code}" - data = { - my_user_id: current_user.id, - my_public_ip: request.remote_ip, - my_device_id: "unknown", - my_client_id: "unknown", + req["Content-Type"] = "application/json" + req.body = { + my_user_id: current_user.id, + my_public_ip: request.remote_ip, + my_device_id: 'unknown', + my_client_id: 'unknown', users: user_ids - } - req.body = data.to_json + }.to_json response = http.request(req) if response.is_a?(Net::HTTPOK) || response.is_a?(Net::HTTPSuccess) render json: response.body, status: 200 else - Bugsnag.notify(exception) do |report| - report.severity = "error" + logger.debug("Latency response failed: #{response}") + Bugsnag.notify("LatencyResponseFailed") do |report| + report.severity = "faliure" report.add_tab(:latency, { user_id: current_user.id, name: current_user.name, user_ids: params[:user_ids], url: latency_url, - body: response.body + code: response.code, + body: response.body, }) end render json: {}, status: 422 end - rescue - Bugsnag.notify("Latency server returned code: #{response.code}") if response + rescue => exception + logger.debug("Latency exception: #{exception.message}") + Bugsnag.notify(exception) do |report| + report.severity = "error" + report.add_tab(:latency, { + user_id: current_user.id, + name: current_user.name, + user_ids: params[:user_ids], + url: latency_url, + }) + end render json: {}, status: 500 end end diff --git a/web/app/views/clients/_hoverMusician.html.erb b/web/app/views/clients/_hoverMusician.html.erb index 39b8277c5..435f2ec4d 100644 --- a/web/app/views/clients/_hoverMusician.html.erb +++ b/web/app/views/clients/_hoverMusician.html.erb @@ -118,7 +118,7 @@
{biography}

Your latency to {first_name} is:   - {latency_badge} +


From 10908623a4119f3e4869e9d5a3438febba2483e6 Mon Sep 17 00:00:00 2001 From: Nuwan Chathuranga Date: Thu, 27 May 2021 15:58:34 +0530 Subject: [PATCH 04/12] wip musician latency badge --- web/app/assets/javascripts/hoverMusician.js | 3 ++- web/app/controllers/api_users_controller.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web/app/assets/javascripts/hoverMusician.js b/web/app/assets/javascripts/hoverMusician.js index 4975a7169..bff33871d 100644 --- a/web/app/assets/javascripts/hoverMusician.js +++ b/web/app/assets/javascripts/hoverMusician.js @@ -190,7 +190,7 @@ var latency; $(document).one('user_latency_update', function(e, latencyResp){ latency = latencyResp['users'][0]; - //logger.debug("bindUserLatencyUpdate", latency) + logger.debug("bindUserLatencyUpdate", latency) if(latency['user_id'] === userId){ showLatencyBadge(latency) } @@ -199,6 +199,7 @@ function bindUserLatencyFail(){ $(document).one('user_latency_fail', function(e, failedUserIds){ + logger.debug("bindUserLatencyFail", failedUserIds) if(_.contains(failedUserIds, userId) || failedUserIds === userId){ showFailedLatencyBadge(userId) } diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 7ffd1eaa2..5d9ab713c 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -956,9 +956,9 @@ class ApiUsersController < ApiController my_client_id: 'unknown', users: user_ids }.to_json - + logger.debug(">>>>>>>>>>>>>>>>>>>>>>> before sending") response = http.request(req) - + logger.debug(">>>>>>>>>>>>>>>>>>>>>>> #{response.inspect}") if response.is_a?(Net::HTTPOK) || response.is_a?(Net::HTTPSuccess) render json: response.body, status: 200 else From 307444431a21bc7cb626da4472c82a287d554820 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Sat, 29 May 2021 14:38:34 +0530 Subject: [PATCH 05/12] wip sepcs for musician latency badge --- admin/.gitignore | 1 + ruby/.gitignore | 1 + web/.gitignore | 1 + .../stores/LatencyStore.js.coffee | 2 +- web/app/controllers/api_users_controller.rb | 8 +-- .../controllers/api_users_controller_spec.rb | 7 +- web/spec/features/musician_hover_spec.rb | 71 +++++++++++++++++++ ...ncy_reponse.json => latency_response.json} | 0 websocket-gateway/.gitignore | 1 + websocket-gateway/Gemfile.lock | 1 + 10 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 web/spec/features/musician_hover_spec.rb rename web/spec/fixtures/{latency_reponse.json => latency_response.json} (100%) diff --git a/admin/.gitignore b/admin/.gitignore index d747d53e8..fae983383 100644 --- a/admin/.gitignore +++ b/admin/.gitignore @@ -22,3 +22,4 @@ artifacts BUILD_NUMBER # Gemfile.lock Gemfile.alt.lock +.byebug_history diff --git a/ruby/.gitignore b/ruby/.gitignore index 048a017ca..fe1f4d2c5 100644 --- a/ruby/.gitignore +++ b/ruby/.gitignore @@ -22,3 +22,4 @@ vendor *~ *.swp *.iml +.byebug_history diff --git a/web/.gitignore b/web/.gitignore index 585c62dfb..3dd570b24 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -42,3 +42,4 @@ public/assets public/uploads /log/*.out BUILD_NUMBER +.byebug_history diff --git a/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee b/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee index d5e6793fa..b4015f319 100644 --- a/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee @@ -22,7 +22,7 @@ rest = new context.JK.Rest() rest.getLatencyToUsers({user_ids: user_ids}).done((response) => @onLoaded(response)).fail((jqXHR) => @onLatencyFail(jqXHR, user_ids)) onLoaded: (response) -> - #logger.debug("LatencyStore.onLoaded", response); + logger.debug("LatencyStore.onLoaded", response); @latencies.push(response) @changed() diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 5d9ab713c..4b26d4530 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -939,8 +939,6 @@ class ApiUsersController < ApiController def get_latencies user_ids = params[:user_ids] - #query_str = user_ids.inject(""){|q, id| q.concat("id=#{id}&")} - #latency_url = "#{Rails.application.config.latency_data_host}/dev/user_latencies/#{current_user.id}?#{query_str}" latency_url = "#{Rails.application.config.latency_data_host}/dev/user_latencies" uri = URI(latency_url) begin @@ -956,9 +954,10 @@ class ApiUsersController < ApiController my_client_id: 'unknown', users: user_ids }.to_json - logger.debug(">>>>>>>>>>>>>>>>>>>>>>> before sending") + response = http.request(req) - logger.debug(">>>>>>>>>>>>>>>>>>>>>>> #{response.inspect}") + #debugger + if response.is_a?(Net::HTTPOK) || response.is_a?(Net::HTTPSuccess) render json: response.body, status: 200 else @@ -977,6 +976,7 @@ class ApiUsersController < ApiController render json: {}, status: 422 end rescue => exception + #debugger logger.debug("Latency exception: #{exception.message}") Bugsnag.notify(exception) do |report| report.severity = "error" diff --git a/web/spec/controllers/api_users_controller_spec.rb b/web/spec/controllers/api_users_controller_spec.rb index f019ea6c3..f1daba6a2 100644 --- a/web/spec/controllers/api_users_controller_spec.rb +++ b/web/spec/controllers/api_users_controller_spec.rb @@ -314,12 +314,13 @@ describe ApiUsersController, type: :controller do describe "get_latencies" do let(:user1) { FactoryGirl.create(:user) } let(:user2) { FactoryGirl.create(:user) } - let(:latency_data_uri) { /\/dev\/user_latencies\// } - let(:response_body) { File.open('./spec/fixtures/latency_reponse.json') } + let(:latency_data_uri) { /\S+\/dev\/user_latencies/ } + let(:response_body) { File.open('./spec/fixtures/latency_response.json') } it "fetch latency graph data" do - stub_request(:get, latency_data_uri) + stub_request(:post, latency_data_uri) .to_return( body: response_body, status: 200) + get :get_latencies, id: user.id, user_ids: [user1, user2].map(&:id).join(',') response.should be_success JSON.parse(response.body)['users'].size.should eq(2) diff --git a/web/spec/features/musician_hover_spec.rb b/web/spec/features/musician_hover_spec.rb new file mode 100644 index 000000000..e0c99ad5e --- /dev/null +++ b/web/spec/features/musician_hover_spec.rb @@ -0,0 +1,71 @@ +require 'spec_helper' +require 'webmock/rspec' + +describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => true do + let(:user1) { FactoryGirl.create(:user) } + let(:user2) { FactoryGirl.create(:user) } + + let(:latency_data_uri) { /\S+\/dev\/user_latencies/ } + + before(:all) do + WebMock.disable_net_connect!(allow_localhost: true) + end + + before(:each) do + fast_signin(user1, "/client") + wait_until_curtain_gone + end + + describe "Latency badge" do + + it "show FAILED" do + response_body = latency_response(user2, -3) #sessionUtils.LATENCY.FAILED: {description: "FAILED", style: "latency-failed", min: -3, max: -3} + stub_request(:post, latency_data_uri) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'FAILED') + end + end + + it "show GOOD" do + response_body = latency_response(user2, 40) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0}, + stub_request(:post, latency_data_uri) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'GOOD') + end + + + def latency_response(user, latency) + { + "users": [ + { + "user_id": user.id, + "first_name": user.first_name, + "last_name": user.last_name, + "audio_latency": 4.0, + "audio_latency_unknown": false, + "ars": { + "internet_latency": latency, + "total_latency": latency + }, + "p2p": { + "internet_latency": latency, + "total_latency": latency + }, + "wifi": false + } + ], + "my_audio_latency": 4.0, + "my_audio_latency_unknown": false + }.to_json + end + +end + diff --git a/web/spec/fixtures/latency_reponse.json b/web/spec/fixtures/latency_response.json similarity index 100% rename from web/spec/fixtures/latency_reponse.json rename to web/spec/fixtures/latency_response.json diff --git a/websocket-gateway/.gitignore b/websocket-gateway/.gitignore index f2b32455d..bb21c2317 100644 --- a/websocket-gateway/.gitignore +++ b/websocket-gateway/.gitignore @@ -25,3 +25,4 @@ log/* target vendor BUILD_NUMBER +.byebug_history diff --git a/websocket-gateway/Gemfile.lock b/websocket-gateway/Gemfile.lock index fb4987b4f..cd6f896f0 100644 --- a/websocket-gateway/Gemfile.lock +++ b/websocket-gateway/Gemfile.lock @@ -578,6 +578,7 @@ DEPENDENCIES newrelic_rpm nokogiri (= 1.10.10) oj (= 3.1.3) + pg (= 0.17.1) postgres-copy postgres_ext protected_attributes From 683e93e75ebba58938a08aa84019225372786d18 Mon Sep 17 00:00:00 2001 From: Nuwan Chathuranga Date: Sat, 29 May 2021 18:43:48 +0530 Subject: [PATCH 06/12] testing latency badge --- web/spec/features/musician_hover_spec.rb | 51 +++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/web/spec/features/musician_hover_spec.rb b/web/spec/features/musician_hover_spec.rb index e0c99ad5e..551d4ed1b 100644 --- a/web/spec/features/musician_hover_spec.rb +++ b/web/spec/features/musician_hover_spec.rb @@ -8,9 +8,14 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => let(:latency_data_uri) { /\S+\/dev\/user_latencies/ } before(:all) do + Capybara.current_driver = :jamkazam WebMock.disable_net_connect!(allow_localhost: true) end + after(:all) do + Capybara.use_default_driver + end + before(:each) do fast_signin(user1, "/client") wait_until_curtain_gone @@ -31,7 +36,7 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => end it "show GOOD" do - response_body = latency_response(user2, 40) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0}, + response_body = latency_response(user2, 0.0) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0}, stub_request(:post, latency_data_uri) .to_return( body: response_body, status: 200) @@ -41,6 +46,50 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => find("#musician-latency-badge div.latency", text: 'GOOD') end + it "show MEDIUM" do + response_body = latency_response(user2, 41) #MEDIUM : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0}, + stub_request(:post, latency_data_uri) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'MEDIUM') + end + + + it "show POOR" do + response_body = latency_response(user2, 71) #POOR : {description: "POOR", style: "latency-poor", min: 70.0, max: 100}, + stub_request(:post, latency_data_uri) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'POOR') + end + + it "show UNACCEPTABLE" do + response_body = latency_response(user2, 101) #UNACCEPTABLE : {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100.0, max: 10000000}, + stub_request(:post, latency_data_uri) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'UNACCEPTABLE') + end + + it "show UNKNOWN" do + response_body = latency_response(user2, -2) #UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2} + stub_request(:post, latency_data_uri) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'UNKNOWN') + end def latency_response(user, latency) { From 4f9ffa6a808ee294c7cd3eaa1c5ba046b2d21442 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Sun, 30 May 2021 07:14:54 +0530 Subject: [PATCH 07/12] testing hover latency badge --- web/spec/features/musician_hover_spec.rb | 186 ++++++++++++----------- 1 file changed, 98 insertions(+), 88 deletions(-) diff --git a/web/spec/features/musician_hover_spec.rb b/web/spec/features/musician_hover_spec.rb index 551d4ed1b..22537431f 100644 --- a/web/spec/features/musician_hover_spec.rb +++ b/web/spec/features/musician_hover_spec.rb @@ -7,23 +7,25 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => let(:latency_data_uri) { /\S+\/dev\/user_latencies/ } - before(:all) do - Capybara.current_driver = :jamkazam + before do + #Capybara.current_driver = :jamkazam WebMock.disable_net_connect!(allow_localhost: true) end - after(:all) do - Capybara.use_default_driver + after do + #Capybara.use_default_driver end before(:each) do fast_signin(user1, "/client") wait_until_curtain_gone + #sleep(1) end + describe "Latency badge" do - it "show FAILED" do + xit "show FAILED", focus: true do response_body = latency_response(user2, -3) #sessionUtils.LATENCY.FAILED: {description: "FAILED", style: "latency-failed", min: -3, max: -3} stub_request(:post, latency_data_uri) .to_return( body: response_body, status: 200) @@ -32,89 +34,97 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent find('h3', text: user2.name) find("#musician-latency-badge div.latency", text: 'FAILED') + sleep(1) end - end - - it "show GOOD" do - response_body = latency_response(user2, 0.0) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0}, - stub_request(:post, latency_data_uri) - .to_return( body: response_body, status: 200) - - site_search(user2.first_name, expand: true) - find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent - find('h3', text: user2.name) - find("#musician-latency-badge div.latency", text: 'GOOD') - end - - it "show MEDIUM" do - response_body = latency_response(user2, 41) #MEDIUM : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0}, - stub_request(:post, latency_data_uri) - .to_return( body: response_body, status: 200) - - site_search(user2.first_name, expand: true) - find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent - find('h3', text: user2.name) - find("#musician-latency-badge div.latency", text: 'MEDIUM') - end - - - it "show POOR" do - response_body = latency_response(user2, 71) #POOR : {description: "POOR", style: "latency-poor", min: 70.0, max: 100}, - stub_request(:post, latency_data_uri) - .to_return( body: response_body, status: 200) - - site_search(user2.first_name, expand: true) - find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent - find('h3', text: user2.name) - find("#musician-latency-badge div.latency", text: 'POOR') - end - - it "show UNACCEPTABLE" do - response_body = latency_response(user2, 101) #UNACCEPTABLE : {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100.0, max: 10000000}, - stub_request(:post, latency_data_uri) - .to_return( body: response_body, status: 200) - - site_search(user2.first_name, expand: true) - find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent - find('h3', text: user2.name) - find("#musician-latency-badge div.latency", text: 'UNACCEPTABLE') - end - - it "show UNKNOWN" do - response_body = latency_response(user2, -2) #UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2} - stub_request(:post, latency_data_uri) - .to_return( body: response_body, status: 200) - - site_search(user2.first_name, expand: true) - find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent - find('h3', text: user2.name) - find("#musician-latency-badge div.latency", text: 'UNKNOWN') - end - - def latency_response(user, latency) - { - "users": [ - { - "user_id": user.id, - "first_name": user.first_name, - "last_name": user.last_name, - "audio_latency": 4.0, - "audio_latency_unknown": false, - "ars": { - "internet_latency": latency, - "total_latency": latency - }, - "p2p": { - "internet_latency": latency, - "total_latency": latency - }, - "wifi": false - } - ], - "my_audio_latency": 4.0, - "my_audio_latency_unknown": false - }.to_json - end -end + it "show POOR", focus: true do + response_body = latency_response(user2, 71.0) #sessionUtils.LATENCY.POOR : {description: "POOR", style: "latency-poor", min: 70.0, max: 100}, + stub_request(:post, latency_data_uri) + .to_return( body: response_body, status: 200) + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'POOR') + sleep(1) + end + + it "show GOOD", focus: true do + response_body = latency_response(user2, 1.0) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0}, + stub_request(:post, latency_data_uri) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'GOOD') + sleep(1) + end + + it "show FAIR", focus: true do + response_body = latency_response(user2, 41.0) #sessionUtils.LATENCY.FAIR : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0}, + stub_request(:post, latency_data_uri) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'FAIR') + sleep(1) + end + + + it "show UNACCEPTABLE", focus: true do + response_body = latency_response(user2, 101.0) #sessionUtils.LATENCY.UNACCEPTABLE : {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100.0, max: 10000000}, + stub_request(:post, latency_data_uri) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'UNACCEPTABLE') + sleep(1) + end + + it "show UNKNOWN", focus: true do + response_body = latency_response(user2, nil) #sessionUtils.LATENCY.UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2} + stub_request(:post, latency_data_uri) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'UNKNOWN') + sleep(1) + end + + def latency_response(user, latency) + resp = { + "users": [ + { + "user_id": user.id, + "first_name": user.first_name, + "last_name": user.last_name, + "audio_latency": 4.0, + "audio_latency_unknown": false, + "ars": { + "internet_latency": latency, + "total_latency": latency + }, + "p2p": { + "internet_latency": latency, + "total_latency": latency + }, + "wifi": false + } + ], + "my_audio_latency": 4.0, + "my_audio_latency_unknown": false + } + #resp[:users][0][:ars][:total_latency] = latency unless latency.nil? + resp.to_json + end + + end + +end From 11d8af22bb7f45988e28d7e15d9f68bbf77b6f95 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Sun, 30 May 2021 22:10:34 +0530 Subject: [PATCH 08/12] fixes to musicion hover latency badge spec --- web/spec/features/musician_hover_spec.rb | 27 +++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/web/spec/features/musician_hover_spec.rb b/web/spec/features/musician_hover_spec.rb index 22537431f..3b180018d 100644 --- a/web/spec/features/musician_hover_spec.rb +++ b/web/spec/features/musician_hover_spec.rb @@ -8,7 +8,9 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => let(:latency_data_uri) { /\S+\/dev\/user_latencies/ } before do - #Capybara.current_driver = :jamkazam + #Capybara.javascript_driver = :capybara_webmock + #Capybara.current_driver = Capybara.javascript_driver + Capybara.default_max_wait_time = 30 # these tests are SLOOOOOW WebMock.disable_net_connect!(allow_localhost: true) end @@ -17,9 +19,8 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => end before(:each) do - fast_signin(user1, "/client") + fast_signin(user1, "/client") wait_until_curtain_gone - #sleep(1) end @@ -28,74 +29,80 @@ describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => xit "show FAILED", focus: true do response_body = latency_response(user2, -3) #sessionUtils.LATENCY.FAILED: {description: "FAILED", style: "latency-failed", min: -3, max: -3} stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .to_return( body: response_body, status: 200) site_search(user2.first_name, expand: true) find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent find('h3', text: user2.name) - find("#musician-latency-badge div.latency", text: 'FAILED') - sleep(1) + find("#musician-latency-badge", text: 'FAILED') + #screenshot_and_save_page end it "show POOR", focus: true do response_body = latency_response(user2, 71.0) #sessionUtils.LATENCY.POOR : {description: "POOR", style: "latency-poor", min: 70.0, max: 100}, stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .to_return( body: response_body, status: 200) site_search(user2.first_name, expand: true) find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent find('h3', text: user2.name) find("#musician-latency-badge div.latency", text: 'POOR') - sleep(1) + end it "show GOOD", focus: true do response_body = latency_response(user2, 1.0) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0}, stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .to_return( body: response_body, status: 200) site_search(user2.first_name, expand: true) find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent find('h3', text: user2.name) find("#musician-latency-badge div.latency", text: 'GOOD') - sleep(1) + end it "show FAIR", focus: true do response_body = latency_response(user2, 41.0) #sessionUtils.LATENCY.FAIR : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0}, stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .to_return( body: response_body, status: 200) site_search(user2.first_name, expand: true) find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent find('h3', text: user2.name) find("#musician-latency-badge div.latency", text: 'FAIR') - sleep(1) + end it "show UNACCEPTABLE", focus: true do response_body = latency_response(user2, 101.0) #sessionUtils.LATENCY.UNACCEPTABLE : {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100.0, max: 10000000}, stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .to_return( body: response_body, status: 200) site_search(user2.first_name, expand: true) find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent find('h3', text: user2.name) find("#musician-latency-badge div.latency", text: 'UNACCEPTABLE') - sleep(1) + end it "show UNKNOWN", focus: true do response_body = latency_response(user2, nil) #sessionUtils.LATENCY.UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2} stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) .to_return( body: response_body, status: 200) site_search(user2.first_name, expand: true) find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent find('h3', text: user2.name) find("#musician-latency-badge div.latency", text: 'UNKNOWN') - sleep(1) + end def latency_response(user, latency) From c7547405f8308d45d5465d4f68448cd43cf9b0e3 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Tue, 1 Jun 2021 20:15:13 +0530 Subject: [PATCH 09/12] Musician hover latency badge show latency score badge on hover over musician. fetches data from new resolve latency data API --- web/app/assets/javascripts/hoverMusician.js | 28 +++- .../stores/LatencyStore.js.coffee | 2 +- web/app/assets/javascripts/session_utils.js | 20 ++- web/app/controllers/api_users_controller.rb | 5 +- web/bin/test | 2 + web/spec/features/musician_hover_spec.rb | 137 ------------------ web/spec/features/musician_hover_spec_1.rb | 75 ++++++++++ web/spec/features/musician_hover_spec_2.rb | 59 ++++++++ web/spec/support/utilities.rb | 33 +++++ 9 files changed, 207 insertions(+), 154 deletions(-) delete mode 100644 web/spec/features/musician_hover_spec.rb create mode 100644 web/spec/features/musician_hover_spec_1.rb create mode 100644 web/spec/features/musician_hover_spec_2.rb diff --git a/web/app/assets/javascripts/hoverMusician.js b/web/app/assets/javascripts/hoverMusician.js index bff33871d..59ca14c50 100644 --- a/web/app/assets/javascripts/hoverMusician.js +++ b/web/app/assets/javascripts/hoverMusician.js @@ -190,17 +190,21 @@ var latency; $(document).one('user_latency_update', function(e, latencyResp){ latency = latencyResp['users'][0]; - logger.debug("bindUserLatencyUpdate", latency) - if(latency['user_id'] === userId){ - showLatencyBadge(latency) + //logger.debug("bindUserLatencyUpdate", latency) + if(latency != undefined){ + if(latency['user_id'] === userId){ + showLatencyBadge(latency) + } + }else{ + showUnknownLatencyBadge(userId); } }); } function bindUserLatencyFail(){ $(document).one('user_latency_fail', function(e, failedUserIds){ - logger.debug("bindUserLatencyFail", failedUserIds) - if(_.contains(failedUserIds, userId) || failedUserIds === userId){ + //logger.debug("bindUserLatencyFail", failedUserIds) + if(_.contains(failedUserIds, userId)){ showFailedLatencyBadge(userId) } }); @@ -223,11 +227,23 @@ "audio_latency": 0, "ars": { "internet_latency": 0, - "total_latency": -3 + "total_latency": -3.0 } }; showLatencyBadge(failedLatency); } + + function showUnknownLatencyBadge(userId){ + var unknownLatency = { + "user_id": userId, + "audio_latency": 0, + "ars": { + "internet_latency": 0, + "total_latency": -2 + } + }; + showLatencyBadge(unknownLatency); + } function unbindUserLatencyUpdate(){ $(document).off('user_latency_update'); diff --git a/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee b/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee index b4015f319..c3f12ab83 100644 --- a/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/LatencyStore.js.coffee @@ -19,7 +19,7 @@ rest = new context.JK.Rest() @trigger(@latencies) onResolve: (user_ids) -> - rest.getLatencyToUsers({user_ids: user_ids}).done((response) => @onLoaded(response)).fail((jqXHR) => @onLatencyFail(jqXHR, user_ids)) + rest.getLatencyToUsers({user_ids: user_ids}).done((response) => @onLoaded(response)).fail((jqXHR) => @onLatencyFail(jqXHR, [user_ids])) onLoaded: (response) -> logger.debug("LatencyStore.onLoaded", response); diff --git a/web/app/assets/javascripts/session_utils.js b/web/app/assets/javascripts/session_utils.js index fcef0cec5..cbddaf972 100644 --- a/web/app/assets/javascripts/session_utils.js +++ b/web/app/assets/javascripts/session_utils.js @@ -101,18 +101,24 @@ iconName = 'purple'; description = 'me'; } - else if (!full_score) { - latencyDescription = LATENCY.UNKNOWN.description; - latencyStyle = LATENCY.UNKNOWN.style; - iconName = 'purple'; - description = 'missing'; - } else if (full_score <= LATENCY.FAILED.max) { latencyDescription = LATENCY.FAILED.description; latencyStyle = LATENCY.FAILED.style; iconName = 'gray'; description = 'failed'; } + // else if (!full_score) { + // latencyDescription = LATENCY.UNKNOWN.description; + // latencyStyle = LATENCY.UNKNOWN.style; + // iconName = 'purple'; + // description = 'missing'; + // } + else if (!full_score || full_score <= LATENCY.UNKNOWN.max) { + latencyDescription = LATENCY.UNKNOWN.description; + latencyStyle = LATENCY.UNKNOWN.style; + iconName = 'purple'; + description = 'missing'; + } else if (full_score <= LATENCY.GOOD.max) { latencyDescription = LATENCY.GOOD.description; latencyStyle = LATENCY.GOOD.style; @@ -131,7 +137,7 @@ iconName = 'red'; description = 'poor'; } - else { + else if (full_score > LATENCY.UNACCEPTABLE.min) { latencyStyle = LATENCY.UNACCEPTABLE.style; latencyDescription = LATENCY.UNACCEPTABLE.description; iconName = 'blue'; diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 4b26d4530..1666529af 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -937,7 +937,6 @@ class ApiUsersController < ApiController #fetch latency information from latency-graph serverless def get_latencies - user_ids = params[:user_ids] latency_url = "#{Rails.application.config.latency_data_host}/dev/user_latencies" uri = URI(latency_url) @@ -973,7 +972,7 @@ class ApiUsersController < ApiController body: response.body, }) end - render json: {}, status: 422 + render json: { user_ids: params[:user_ids] }, status: 422 end rescue => exception #debugger @@ -987,7 +986,7 @@ class ApiUsersController < ApiController url: latency_url, }) end - render json: {}, status: 500 + render json: { user_ids: params[:user_ids] }, status: 500 end end diff --git a/web/bin/test b/web/bin/test index b08d6a26e..513c7a260 100755 --- a/web/bin/test +++ b/web/bin/test @@ -10,6 +10,8 @@ tests=( "spec/features/affiliate_program_spec.rb" "spec/features/affiliate_visit_tracking_spec.rb" "spec/features/affiliate_referral_spec.rb" + "spec/features/musician_hover_spec_1.rb" + "spec/features/musician_hover_spec_2.rb" "spec/controllers/api_affiliate_controller_spec.rb" ) diff --git a/web/spec/features/musician_hover_spec.rb b/web/spec/features/musician_hover_spec.rb deleted file mode 100644 index 3b180018d..000000000 --- a/web/spec/features/musician_hover_spec.rb +++ /dev/null @@ -1,137 +0,0 @@ -require 'spec_helper' -require 'webmock/rspec' - -describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => true do - let(:user1) { FactoryGirl.create(:user) } - let(:user2) { FactoryGirl.create(:user) } - - let(:latency_data_uri) { /\S+\/dev\/user_latencies/ } - - before do - #Capybara.javascript_driver = :capybara_webmock - #Capybara.current_driver = Capybara.javascript_driver - Capybara.default_max_wait_time = 30 # these tests are SLOOOOOW - WebMock.disable_net_connect!(allow_localhost: true) - end - - after do - #Capybara.use_default_driver - end - - before(:each) do - fast_signin(user1, "/client") - wait_until_curtain_gone - end - - - describe "Latency badge" do - - xit "show FAILED", focus: true do - response_body = latency_response(user2, -3) #sessionUtils.LATENCY.FAILED: {description: "FAILED", style: "latency-failed", min: -3, max: -3} - stub_request(:post, latency_data_uri) - .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) - .to_return( body: response_body, status: 200) - - site_search(user2.first_name, expand: true) - find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent - find('h3', text: user2.name) - find("#musician-latency-badge", text: 'FAILED') - #screenshot_and_save_page - end - - it "show POOR", focus: true do - response_body = latency_response(user2, 71.0) #sessionUtils.LATENCY.POOR : {description: "POOR", style: "latency-poor", min: 70.0, max: 100}, - stub_request(:post, latency_data_uri) - .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) - .to_return( body: response_body, status: 200) - - site_search(user2.first_name, expand: true) - find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent - find('h3', text: user2.name) - find("#musician-latency-badge div.latency", text: 'POOR') - - end - - it "show GOOD", focus: true do - response_body = latency_response(user2, 1.0) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0}, - stub_request(:post, latency_data_uri) - .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) - .to_return( body: response_body, status: 200) - - site_search(user2.first_name, expand: true) - find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent - find('h3', text: user2.name) - find("#musician-latency-badge div.latency", text: 'GOOD') - - end - - it "show FAIR", focus: true do - response_body = latency_response(user2, 41.0) #sessionUtils.LATENCY.FAIR : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0}, - stub_request(:post, latency_data_uri) - .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) - .to_return( body: response_body, status: 200) - - site_search(user2.first_name, expand: true) - find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent - find('h3', text: user2.name) - find("#musician-latency-badge div.latency", text: 'FAIR') - - end - - - it "show UNACCEPTABLE", focus: true do - response_body = latency_response(user2, 101.0) #sessionUtils.LATENCY.UNACCEPTABLE : {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100.0, max: 10000000}, - stub_request(:post, latency_data_uri) - .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) - .to_return( body: response_body, status: 200) - - site_search(user2.first_name, expand: true) - find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent - find('h3', text: user2.name) - find("#musician-latency-badge div.latency", text: 'UNACCEPTABLE') - - end - - it "show UNKNOWN", focus: true do - response_body = latency_response(user2, nil) #sessionUtils.LATENCY.UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2} - stub_request(:post, latency_data_uri) - .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) - .to_return( body: response_body, status: 200) - - site_search(user2.first_name, expand: true) - find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent - find('h3', text: user2.name) - find("#musician-latency-badge div.latency", text: 'UNKNOWN') - - end - - def latency_response(user, latency) - resp = { - "users": [ - { - "user_id": user.id, - "first_name": user.first_name, - "last_name": user.last_name, - "audio_latency": 4.0, - "audio_latency_unknown": false, - "ars": { - "internet_latency": latency, - "total_latency": latency - }, - "p2p": { - "internet_latency": latency, - "total_latency": latency - }, - "wifi": false - } - ], - "my_audio_latency": 4.0, - "my_audio_latency_unknown": false - } - #resp[:users][0][:ars][:total_latency] = latency unless latency.nil? - resp.to_json - end - - end - -end diff --git a/web/spec/features/musician_hover_spec_1.rb b/web/spec/features/musician_hover_spec_1.rb new file mode 100644 index 000000000..c0c877eed --- /dev/null +++ b/web/spec/features/musician_hover_spec_1.rb @@ -0,0 +1,75 @@ +require 'spec_helper' +require 'webmock/rspec' + +#NOTE: The rest of the tests related to musician latency badge are in +#musician_hover_spec_2.rb file. For some uncertain issue getting all these +#tests in a single file doesn't work because some of them fail without a reason. +#Probably because of webmock behaving wiredly. + +describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => true do + let(:user1) { FactoryGirl.create(:user) } + let(:user2) { FactoryGirl.create(:user) } + + let(:latency_data_uri) { /\S+\/dev\/user_latencies/ } + + before do + Capybara.default_max_wait_time = 30 # these tests are SLOOOOOW + WebMock.disable_net_connect!(allow_localhost: true) + end + + before(:each) do + fast_signin(user1, "/client") + wait_until_curtain_gone + end + + describe "Latency badge" do + it "show ME (same user)" do + response_body = mock_latency_response(user1, 1.0) #sessionUtils.LATENCY.UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2} + stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) + .to_return( body: response_body, status: 200) + + site_search(user1.first_name, expand: true) + find("#search-results a[user-id=\"#{user1.id}\"][hoveraction=\"musician\"]", text: user1.name).hover_intent + find('h3', text: user1.name) + find("#musician-latency-badge div.latency", text: 'ME') + end + + it "show FAILED" do + stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) + .to_raise("some error") + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge", text: 'FAILED') + end + + it "show UNKNOWN" do + response_body = mock_latency_response(user2, nil) #sessionUtils.LATENCY.UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2} + stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'UNKNOWN') + end + + it "show GOOD" do + response_body = mock_latency_response(user2, 1.0) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0}, + stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'GOOD') + end + + end + +end diff --git a/web/spec/features/musician_hover_spec_2.rb b/web/spec/features/musician_hover_spec_2.rb new file mode 100644 index 000000000..66be2abbc --- /dev/null +++ b/web/spec/features/musician_hover_spec_2.rb @@ -0,0 +1,59 @@ +require 'spec_helper' +require 'webmock/rspec' + +describe "Musician Hover", :js => true, :type => :feature, :capybara_feature => true do + let(:user1) { FactoryGirl.create(:user) } + let(:user2) { FactoryGirl.create(:user) } + + let(:latency_data_uri) { /\S+\/dev\/user_latencies/ } + + before do + Capybara.default_max_wait_time = 30 # these tests are SLOOOOOW + WebMock.disable_net_connect!(allow_localhost: true) + end + + before(:each) do + fast_signin(user1, "/client") + wait_until_curtain_gone + end + + describe "Latency badge" do + it "show POOR" do + response_body = mock_latency_response(user2, 71.0) #sessionUtils.LATENCY.POOR : {description: "POOR", style: "latency-poor", min: 70.0, max: 100}, + stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'POOR') + end + + it "show FAIR" do + response_body = mock_latency_response(user2, 41.0) #sessionUtils.LATENCY.FAIR : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0}, + stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'FAIR') + end + + it "show UNACCEPTABLE", focus: true do + response_body = mock_latency_response(user2, 101.0) #sessionUtils.LATENCY.UNACCEPTABLE : {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100.0, max: 10000000}, + stub_request(:post, latency_data_uri) + .with(:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}) + .to_return( body: response_body, status: 200) + + site_search(user2.first_name, expand: true) + find("#search-results a[user-id=\"#{user2.id}\"][hoveraction=\"musician\"]", text: user2.name).hover_intent + find('h3', text: user2.name) + find("#musician-latency-badge div.latency", text: 'UNACCEPTABLE') + end + + end + +end diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb index be5bdc431..665e9ec72 100644 --- a/web/spec/support/utilities.rb +++ b/web/spec/support/utilities.rb @@ -795,4 +795,37 @@ end def nav_profile_history(user) visit Nav.profile(user) find('#history-link').trigger(:click) +end + +def mock_latency_response(user, latency) + resp = nil + if latency + resp = { + "users": [ + { + "user_id": user.id, + "first_name": user.first_name, + "last_name": user.last_name, + "audio_latency": 4.0, + "audio_latency_unknown": false, + "ars": { + "internet_latency": latency, + "total_latency": latency + }, + "p2p": { + "internet_latency": latency, + "total_latency": latency + }, + "wifi": false + } + ], + "my_audio_latency": 4.0, + "my_audio_latency_unknown": false + } + else + resp = { + "users": [] + } + end + return resp.to_json end \ No newline at end of file From 1ee14dd01a82b2d92213e4f5a0598df6c0664ba1 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Tue, 1 Jun 2021 21:39:09 +0530 Subject: [PATCH 10/12] fix small spelling mistake --- .../javascripts/react-components/FindSessionOpen.js.jsx.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/app/assets/javascripts/react-components/FindSessionOpen.js.jsx.coffee b/web/app/assets/javascripts/react-components/FindSessionOpen.js.jsx.coffee index cda48a101..e0f1bd47a 100644 --- a/web/app/assets/javascripts/react-components/FindSessionOpen.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/FindSessionOpen.js.jsx.coffee @@ -24,7 +24,7 @@ SessionsActions = @SessionsActions `

How This Page Works

This page will show only public jam sessions.

-

Most recent sessions are shown an the top.

+

Most recent sessions are shown at the top.

This list of public sessions does not auto-update. You will have to push the REFRESH button to see new sessions.

` else if this.props.mode == 'my' From 047ae3ebb222b79c5dd56301a9194346dd1c9f68 Mon Sep 17 00:00:00 2001 From: Nuwan Chathuranga Date: Fri, 4 Jun 2021 00:16:07 +0530 Subject: [PATCH 11/12] specify latency server url correctly --- web/app/controllers/api_users_controller.rb | 2 +- web/config/environments/development.rb | 2 +- web/config/environments/test.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 1666529af..b3849a0c5 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -938,7 +938,7 @@ class ApiUsersController < ApiController #fetch latency information from latency-graph serverless def get_latencies user_ids = params[:user_ids] - latency_url = "#{Rails.application.config.latency_data_host}/dev/user_latencies" + latency_url = "#{Rails.application.config.latency_data_host}/user_latencies" uri = URI(latency_url) begin http = Net::HTTP.new(uri.host, uri.port) diff --git a/web/config/environments/development.rb b/web/config/environments/development.rb index 478424b43..c0b3bf258 100644 --- a/web/config/environments/development.rb +++ b/web/config/environments/development.rb @@ -114,6 +114,6 @@ SampleApp::Application.configure do config.video_conferencing_host = "https://webrtc-demo.jamkazam.com" config.use_video_conferencing_server = true - config.latency_data_host = "http://localhost:4001" + config.latency_data_host = "http://localhost:4001/dev" config.latency_data_host_auth_code = "c2VydmVyOnBhc3N3b3Jk" end diff --git a/web/config/environments/test.rb b/web/config/environments/test.rb index e2627130e..61e785a9f 100644 --- a/web/config/environments/test.rb +++ b/web/config/environments/test.rb @@ -133,7 +133,7 @@ SampleApp::Application.configure do config.video_conferencing_host = "https://webrtc-demo.jamkazam.com" config.use_video_conferencing_server = false - config.latency_data_host = "http://localhost:4001" + config.latency_data_host = "http://localhost:4001/test" config.latency_data_host_auth_code = "c2VydmVyOnBhc3N3b3Jk" end From 87a01bcd6648bcc5e8b9c669f1faa3f62f13be5e Mon Sep 17 00:00:00 2001 From: Nuwan Chathuranga Date: Fri, 4 Jun 2021 00:21:30 +0530 Subject: [PATCH 12/12] remove "unknown" parameters in get_latencies api call to latency server --- web/app/controllers/api_users_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index b3849a0c5..9ad0f52f2 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -949,8 +949,8 @@ class ApiUsersController < ApiController req.body = { my_user_id: current_user.id, my_public_ip: request.remote_ip, - my_device_id: 'unknown', - my_client_id: 'unknown', + my_device_id: nil, + my_client_id: nil, users: user_ids }.to_json