change latency values of FAIR category
This commit is contained in:
parent
97b1b03946
commit
7a86300755
|
|
@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
const JKLatencyBadge = ({ latencyData, showAll }) => {
|
||||
|
||||
const LATENCY_SCORES = {
|
||||
good: { label: 'GOOD', min: 0, max: 40 },
|
||||
fair: { label: 'FAIR', min: 40, max: 80 },
|
||||
|
|
|
|||
|
|
@ -1,5 +1,15 @@
|
|||
module LatencyHelper
|
||||
|
||||
#GOOD = <40ms, FAIR = 40-60ms, and POOR = >60ms
|
||||
|
||||
LATENCY_SCORES = {
|
||||
good: { label: 'GOOD', min: 0, max: 40 },
|
||||
fair: { label: 'FAIR', min: 40, max: 60 },
|
||||
high: { label: 'HIGH', min: 60, max: 10000000 },
|
||||
me: { label: 'ME', min: -1, max: -1 },
|
||||
unknown: { label: 'UNKNOWN', min: -2, max: -2 }
|
||||
};
|
||||
|
||||
def users_latency_data(latency_good, latency_fair, latency_high)
|
||||
latency_data = []
|
||||
if latency_good || latency_fair || latency_high
|
||||
|
|
@ -22,6 +32,7 @@ module LatencyHelper
|
|||
if response.is_a?(Net::HTTPOK) || response.is_a?(Net::HTTPSuccess)
|
||||
graph_db_users = JSON.parse(response.body)["users"]
|
||||
if latency_good || latency_fair || latency_high
|
||||
#fiter by latency params
|
||||
graph_db_users.select! do |user|
|
||||
total_latency = user["ars"]["total_latency"].to_f
|
||||
(total_latency >= LATENCY_SCORES[:good][:min] && total_latency <= LATENCY_SCORES[:good][:max] && latency_good) ||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
require 'spec_helper'
|
||||
require 'webmock/rspec'
|
||||
|
||||
#GOOD = <40ms, FAIR = 40-60ms, and POOR = >60ms
|
||||
|
||||
describe "Musician Filter API", type: :request do
|
||||
let(:user) { FactoryGirl.create(:user) }
|
||||
|
||||
|
|
@ -18,8 +20,8 @@ describe "Musician Filter API", type: :request do
|
|||
{ user: user1, ars_total_latency: 1.0, ars_internet_latency: 0.4, audio_latency: 0.6 }, #GOOD
|
||||
{ user: user2, ars_total_latency: 40.0, ars_internet_latency: 25.0, audio_latency: 15.0 }, #GOOD
|
||||
{ user: user3, ars_total_latency: 40.1, ars_internet_latency: 25, audio_latency: 15.1 }, #FAIR
|
||||
{ user: user4, ars_total_latency: 80.0, ars_internet_latency: 40, audio_latency: 40.0 }, #FAIR
|
||||
{ user: user5, ars_total_latency: 80.1, ars_internet_latency: 40.1, audio_latency: 40 }, #HIGH
|
||||
{ user: user4, ars_total_latency: 60.0, ars_internet_latency: 30, audio_latency: 30.0 }, #FAIR
|
||||
{ user: user5, ars_total_latency: 60.1, ars_internet_latency: 30.1, audio_latency: 30 }, #HIGH
|
||||
{ user: user6, ars_total_latency: 100.0, ars_internet_latency: 50.0, audio_latency: 50.0 }, #HIGH
|
||||
{ user: user7, ars_total_latency: -2, ars_internet_latency: -1, audio_latency: -1 } #UNKNOWN
|
||||
])
|
||||
|
|
@ -184,7 +186,7 @@ describe "Musician Filter API", type: :request do
|
|||
expect(JSON.parse(response.body)["musicians"].size).to eq(2)
|
||||
end
|
||||
|
||||
describe "number of days ago they last active", focus: true do
|
||||
describe "number of days ago they last active" do
|
||||
|
||||
before(:each) do
|
||||
User.update_all(updated_at: 91.days.ago, last_jam_updated_at: 91.days.ago)
|
||||
|
|
@ -196,20 +198,20 @@ describe "Musician Filter API", type: :request do
|
|||
expect(JSON.parse(response.body)["musicians"].size).to eq(1)
|
||||
end
|
||||
|
||||
it "finds user last_jam_updated is within a day ago", focus: true do
|
||||
it "finds user last_jam_updated is within a day ago" do
|
||||
user1.update_column(:last_jam_updated_at, 1.day.ago)
|
||||
post '/api/filter.json', { latency_good: true, latency_fair: true, latency_high: true, active_within_days: 1 }
|
||||
expect(JSON.parse(response.body)["musicians"].size).to eq(1)
|
||||
end
|
||||
|
||||
it "finds user updated_at and last_jam_updated is within a day ago", focus: true do
|
||||
it "finds user updated_at and last_jam_updated is within a day ago" do
|
||||
user1.update_column(:last_jam_updated_at, 1.day.ago)
|
||||
user1.update_column(:updated_at, 1.day.ago)
|
||||
post '/api/filter.json', { latency_good: true, latency_fair: true, latency_high: true, active_within_days: 1 }
|
||||
expect(JSON.parse(response.body)["musicians"].size).to eq(1)
|
||||
end
|
||||
|
||||
it "finds users updated_at and last_jam_updated within 90 days ago", focus: true do
|
||||
it "finds users updated_at and last_jam_updated within 90 days ago" do
|
||||
user1.update_column(:last_jam_updated_at, 1.day.ago)
|
||||
user1.update_column(:updated_at, 7.day.ago)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue