wip sepcs for musician latency badge
This commit is contained in:
parent
10908623a4
commit
307444431a
|
|
@ -22,3 +22,4 @@ artifacts
|
|||
BUILD_NUMBER
|
||||
# Gemfile.lock
|
||||
Gemfile.alt.lock
|
||||
.byebug_history
|
||||
|
|
|
|||
|
|
@ -22,3 +22,4 @@ vendor
|
|||
*~
|
||||
*.swp
|
||||
*.iml
|
||||
.byebug_history
|
||||
|
|
|
|||
|
|
@ -42,3 +42,4 @@ public/assets
|
|||
public/uploads
|
||||
/log/*.out
|
||||
BUILD_NUMBER
|
||||
.byebug_history
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
@ -25,3 +25,4 @@ log/*
|
|||
target
|
||||
vendor
|
||||
BUILD_NUMBER
|
||||
.byebug_history
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue