fix: 分数计算逻辑调整
This commit is contained in:
@@ -780,66 +780,48 @@ export function getChainRatio (current, prev) {
|
||||
}
|
||||
}
|
||||
|
||||
export function computeScore (data, index) {
|
||||
export function computeScore (data) {
|
||||
let score = 0
|
||||
let k = 0
|
||||
if (index === 0) {
|
||||
k = 0.3
|
||||
if (!data.establishLatencyMs && data.establishLatencyMs !== 0) {
|
||||
score = 0
|
||||
} else if (data.establishLatencyMs <= 50) {
|
||||
score = 1
|
||||
} else if (data.establishLatencyMs > 200) {
|
||||
score = 0
|
||||
} else {
|
||||
score = (data.establishLatencyMs - 200) / (50 - 200)
|
||||
let totalScore = 0
|
||||
const scoreArr = []
|
||||
Object.keys(data).forEach(t => {
|
||||
if (t === 'establishLatencyMs' || t === 'tcpLostlenPercent' || t === 'pktRetransPercent') {
|
||||
k = 0.3
|
||||
} else if (t === 'httpResponseLatency' || t === 'sslConLatency') {
|
||||
k = 0.05
|
||||
}
|
||||
} else if (index === 1) {
|
||||
k = 0.05
|
||||
if (!data.httpResponseLatency && data.httpResponseLatency !== 0) {
|
||||
score = 1
|
||||
} else if (data.httpResponseLatency <= 50) {
|
||||
score = 1
|
||||
} else if (data.httpResponseLatency > 200) {
|
||||
score = 0
|
||||
} else {
|
||||
score = (data.httpResponseLatency - 200) / (50 - 200)
|
||||
}
|
||||
} else if (index === 2) {
|
||||
k = 0.05
|
||||
if (!data.sslConLatency && data.sslConLatency !== 0) {
|
||||
score = 1
|
||||
} else if (data.sslConLatency <= 50) {
|
||||
score = 1
|
||||
} else if (data.sslConLatency > 200) {
|
||||
score = 0
|
||||
} else {
|
||||
score = (data.sslConLatency - 200) / (50 - 200)
|
||||
}
|
||||
} else if (index === 3) {
|
||||
k = 0.3
|
||||
if (!data.tcpLostlenPercent && data.tcpLostlenPercent !== 0) {
|
||||
score = 0
|
||||
} else if (data.tcpLostlenPercent <= 0.01) {
|
||||
score = 1
|
||||
} else if (data.tcpLostlenPercent > 0.05) {
|
||||
score = 0
|
||||
} else {
|
||||
score = (data.tcpLostlenPercent - 0.05) / (0.01 - 0.05)
|
||||
}
|
||||
} else if (index === 4) {
|
||||
k = 0.3
|
||||
if (!data.pktRetransPercent && data.pktRetransPercent !== 0) {
|
||||
score = 0
|
||||
} else if (data.pktRetransPercent <= 0.01) {
|
||||
score = 1
|
||||
} else if (data.pktRetransPercent > 0.05) {
|
||||
score = 0
|
||||
} else {
|
||||
score = (data.pktRetransPercent - 0.05) / (0.01 - 0.05)
|
||||
if (t === 'establishLatencyMs' || t === 'httpResponseLatency' || t === 'sslConLatency') {
|
||||
if (!data[t] && data[t] !== 0) {
|
||||
score = 0
|
||||
} else if (data[t] <= 50) {
|
||||
score = 1
|
||||
} else if (data[t] > 200) {
|
||||
score = 0
|
||||
} else {
|
||||
score = (data[t] - 200) / (50 - 200)
|
||||
}
|
||||
} else if (t === 'tcpLostlenPercent' || t === 'pktRetransPercent') {
|
||||
if (!data[t] && data[t] !== 0) {
|
||||
score = 0
|
||||
} else if (data[t] <= 0.01) {
|
||||
score = 1
|
||||
} else if (data[t] > 0.05) {
|
||||
score = 0
|
||||
} else {
|
||||
score = (data[t] - 0.05) / (0.01 - 0.05)
|
||||
}
|
||||
}
|
||||
scoreArr.push(score * k)
|
||||
})
|
||||
scoreArr.forEach(t => {
|
||||
totalScore += t
|
||||
})
|
||||
totalScore = Math.ceil(totalScore * 6)
|
||||
if (totalScore > 6) {
|
||||
totalScore = 6
|
||||
}
|
||||
return score * k
|
||||
return totalScore
|
||||
}
|
||||
|
||||
// 改变tab状态(url中):当前tab,
|
||||
|
||||
@@ -236,17 +236,16 @@ export default {
|
||||
* 本地计算npm分数
|
||||
*/
|
||||
localComputeScore (data, bandwidth) {
|
||||
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
|
||||
let score = 0
|
||||
keyPre.forEach((item, index) => {
|
||||
score = computeScore(data, index)
|
||||
data[keyPre[index] + 'Score'] = score
|
||||
})
|
||||
let npmScore = Math.ceil((data.tcpScore + data.httpScore + data.sslScore + data.tcpLostScore + data.packetRetransScore) * 6)
|
||||
if (npmScore > 6) {
|
||||
npmScore = 6
|
||||
const dataScore = {
|
||||
establishLatencyMs: data.establishLatencyMs || null,
|
||||
httpResponseLatency: data.httpResponseLatency || null,
|
||||
sslConLatency: data.sslConLatency || null,
|
||||
tcpLostlenPercent: data.tcpLostlenPercent || null,
|
||||
pktRetransPercent: data.pktRetransPercent || null
|
||||
}
|
||||
return npmScore
|
||||
score = computeScore(dataScore)
|
||||
return score
|
||||
},
|
||||
/**
|
||||
* 计算popover弹窗和右侧数据模块的宽度
|
||||
|
||||
@@ -130,17 +130,15 @@ export default {
|
||||
get(api.linkMonitor.networkAnalysis, params).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.isNoData = res.data.result.length === 0
|
||||
const dataArr = [0, 1, 2, 3, 4]
|
||||
let scoreAll = 0
|
||||
dataArr.forEach(e => {
|
||||
const score = computeScore(res.data.result[0], e)
|
||||
scoreAll += score
|
||||
})
|
||||
this.linkTrafficListData = res.data.result[0]
|
||||
this.linkTrafficListData.npmScore = Math.ceil(scoreAll * 6)
|
||||
if (this.linkTrafficListData.npmScore > 6) {
|
||||
this.linkTrafficListData.npmScore = 6
|
||||
const data = {
|
||||
establishLatencyMs: res.data.result[0].establishLatencyMs || null,
|
||||
httpResponseLatency: res.data.result[0].httpResponseLatency || null,
|
||||
sslConLatency: res.data.result[0].sslConLatency || null,
|
||||
tcpLostlenPercent: res.data.result[0].tcpLostlenPercent || null,
|
||||
pktRetransPercent: res.data.result[0].pktRetransPercent || null
|
||||
}
|
||||
this.linkTrafficListData = res.data.result[0]
|
||||
this.linkTrafficListData.npmScore = computeScore(data)
|
||||
}
|
||||
}).catch(e => {
|
||||
console.error(e)
|
||||
|
||||
@@ -134,7 +134,14 @@ import unitConvert from '@/utils/unit-convert'
|
||||
import { api } from '@/utils/api'
|
||||
import { getSecond } from '@/utils/date-util'
|
||||
import { get } from '@/utils/http'
|
||||
import { getChainRatio, computeScore, changeCurTab, urlParamsHandler, overwriteUrl, getUserDrilldownTableConfig } from '@/utils/tools'
|
||||
import {
|
||||
getChainRatio,
|
||||
computeScore,
|
||||
changeCurTab,
|
||||
urlParamsHandler,
|
||||
overwriteUrl,
|
||||
getUserDrilldownTableConfig
|
||||
} from '@/utils/tools'
|
||||
import chartMixin from '@/views/charts2/chart-mixin'
|
||||
import ChartNoData from '@/views/charts/charts/ChartNoData'
|
||||
export default {
|
||||
@@ -220,24 +227,20 @@ export default {
|
||||
res.forEach((r, i) => {
|
||||
if (r.code === 200) {
|
||||
tableData.forEach(t => {
|
||||
let score = 0
|
||||
const find = r.data.result.find(d => d.appSubcategory === t.appSubcategory)
|
||||
if (find) {
|
||||
score = computeScore(find, i)
|
||||
}
|
||||
t[keyPre[i] + 'Score'] = score
|
||||
})
|
||||
} else {
|
||||
tableData.forEach(t => {
|
||||
t[keyPre[i] + 'Score'] = 0
|
||||
t[keyPre[i] + 'Score'] = find
|
||||
})
|
||||
}
|
||||
})
|
||||
tableData.forEach(t => {
|
||||
t.score = Math.ceil((t.tcpScore + t.httpScore + t.sslScore + t.tcpLostScore + t.packetRetransScore) * 6)
|
||||
if (t.score > 6) {
|
||||
t.score = 6
|
||||
const data = {
|
||||
establishLatencyMs: t.tcpScore ? t.tcpScore.establishLatencyMs : null,
|
||||
httpResponseLatency: t.httpScore ? t.httpScore.httpResponseLatency : null,
|
||||
sslConLatency: t.sslScore ? t.sslScore.sslConLatency : null,
|
||||
tcpLostlenPercent: t.tcpLostScore ? t.tcpLostScore.tcpLostlenPercent : null,
|
||||
pktRetransPercent: t.packetRetransScore ? t.packetRetransScore.pktRetransPercent : null
|
||||
}
|
||||
t.score = computeScore(data)
|
||||
})
|
||||
this.tableData = tableData
|
||||
}).finally(() => {
|
||||
|
||||
@@ -107,24 +107,20 @@ export default {
|
||||
res2.forEach((r, i) => {
|
||||
if (r.code === 200) {
|
||||
mapData.forEach(t => {
|
||||
let score = 0
|
||||
const find = r.data.result.find(d => d.country === t.country)
|
||||
if (find) {
|
||||
score = computeScore(find, i)
|
||||
}
|
||||
t[keyPre[i] + 'Score'] = score
|
||||
})
|
||||
} else {
|
||||
mapData.forEach(t => {
|
||||
t[keyPre[i] + 'Score'] = 0
|
||||
t[keyPre[i] + 'Score'] = find
|
||||
})
|
||||
}
|
||||
})
|
||||
mapData.forEach(t => {
|
||||
t.score = Math.ceil((t.tcpScore + t.httpScore + t.sslScore + t.tcpLostScore + t.packetRetransScore) * 6)
|
||||
if (t.score > 6) {
|
||||
t.score = 6
|
||||
const data = {
|
||||
establishLatencyMs: t.tcpScore ? t.tcpScore.establishLatencyMs : null,
|
||||
httpResponseLatency: t.httpScore ? t.httpScore.httpResponseLatency : null,
|
||||
sslConLatency: t.sslScore ? t.sslScore.sslConLatency : null,
|
||||
tcpLostlenPercent: t.tcpLostScore ? t.tcpLostScore.tcpLostlenPercent : null,
|
||||
pktRetransPercent: t.packetRetransScore ? t.packetRetransScore.pktRetransPercent : null
|
||||
}
|
||||
t.score = computeScore(data)
|
||||
})
|
||||
this.loadMarkerData(imageSeries, mapData)
|
||||
})
|
||||
|
||||
@@ -129,24 +129,20 @@ export default {
|
||||
res2.forEach((r, i) => {
|
||||
if (r.code === 200) {
|
||||
mapData.forEach(t => {
|
||||
let score = 0
|
||||
const find = r.data.result.find(d => d.country === t.country)
|
||||
if (find) {
|
||||
score = computeScore(find, i)
|
||||
}
|
||||
t[keyPre[i] + 'Score'] = score
|
||||
})
|
||||
} else {
|
||||
mapData.forEach(t => {
|
||||
t[keyPre[i] + 'Score'] = 0
|
||||
t[keyPre[i] + 'Score'] = find
|
||||
})
|
||||
}
|
||||
})
|
||||
mapData.forEach(t => {
|
||||
t.score = Math.ceil((t.tcpScore + t.httpScore + t.sslScore + t.tcpLostScore + t.packetRetransScore) * 6)
|
||||
if (t.score > 6) {
|
||||
t.score = 6
|
||||
const data = {
|
||||
establishLatencyMs: t.tcpScore ? t.tcpScore.establishLatencyMs : null,
|
||||
httpResponseLatency: t.httpScore ? t.httpScore.httpResponseLatency : null,
|
||||
sslConLatency: t.sslScore ? t.sslScore.sslConLatency : null,
|
||||
tcpLostlenPercent: t.tcpLostScore ? t.tcpLostScore.tcpLostlenPercent : null,
|
||||
pktRetransPercent: t.packetRetransScore ? t.packetRetransScore.pktRetransPercent : null
|
||||
}
|
||||
t.score = computeScore(data)
|
||||
})
|
||||
this.loadMarkerData(imageSeries, mapData)
|
||||
})
|
||||
|
||||
@@ -98,43 +98,19 @@ export default {
|
||||
if (type && condition) {
|
||||
this.toggleLoading(true)
|
||||
get(api.npm.overview.networkAnalysis, params).then(res => {
|
||||
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
|
||||
const scoreInfo = {}
|
||||
let index = 0
|
||||
let score = 0
|
||||
if (res.code === 200) {
|
||||
if (res.data.result.establishLatencyMsAvg || res.data.result.establishLatencyMsAvg === 0) {
|
||||
res.data.result.establishLatencyMs = res.data.result.establishLatencyMsAvg
|
||||
index = 0
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
||||
const data = {
|
||||
establishLatencyMs: res.data.result.establishLatencyMsAvg || null,
|
||||
httpResponseLatency: res.data.result.httpResponseLatencyAvg || null,
|
||||
sslConLatency: res.data.result.sslConLatencyAvg || null,
|
||||
tcpLostlenPercent: res.data.result.tcpLostlenPercentAvg || null,
|
||||
pktRetransPercent: res.data.result.pktRetransPercentAvg || null
|
||||
}
|
||||
if (res.data.result.httpResponseLatencyAvg || res.data.result.httpResponseLatencyAvg === 0) {
|
||||
res.data.result.httpResponseLatency = res.data.result.httpResponseLatencyAvg
|
||||
index = 1
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
||||
}
|
||||
if (res.data.result.tcpLostlenPercentAvg || res.data.result.tcpLostlenPercentAvg === 0) {
|
||||
res.data.result.tcpLostlenPercent = res.data.result.tcpLostlenPercentAvg
|
||||
index = 3
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
||||
}
|
||||
if (res.data.result.pktRetransPercentAvg || res.data.result.pktRetransPercentAvg === 0) {
|
||||
res.data.result.pktRetransPercent = res.data.result.pktRetransPercentAvg
|
||||
index = 4
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
||||
}
|
||||
if (res.data.result.sslConLatencyAvg || res.data.result.sslConLatencyAvg === 0) {
|
||||
res.data.result.sslConLatency = res.data.result.sslConLatencyAvg
|
||||
index = 2
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(res.data.result, index)
|
||||
}
|
||||
this.npmNetworkCycleData = res.data.result
|
||||
score = computeScore(data)
|
||||
this.npmNetworkLastCycleQuery()
|
||||
}
|
||||
scoreInfo.score = Math.ceil((scoreInfo.tcpScore + scoreInfo.httpScore + scoreInfo.sslScore + scoreInfo.tcpLostScore + scoreInfo.packetRetransScore) * 6)
|
||||
if (scoreInfo.score > 6) {
|
||||
scoreInfo.score = 6
|
||||
}
|
||||
this.$store.commit('setNpmThirdLevelMenuScore', scoreInfo.score)
|
||||
this.$store.commit('setNpmThirdLevelMenuScore', score)
|
||||
}).catch(e => {
|
||||
this.toggleLoading(false)
|
||||
})
|
||||
@@ -147,40 +123,21 @@ export default {
|
||||
this.toggleLoading(true)
|
||||
Promise.all([tcp, http, ssl, tcpPercent, packetPercent]).then(res => {
|
||||
this.npmNetworkCycleData = []
|
||||
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
|
||||
const scoreInfo = {}
|
||||
let index = 0
|
||||
let score = 0
|
||||
res.forEach(t => {
|
||||
if (t.code === 200) {
|
||||
if (t.data.result.establishLatencyMsAvg || t.data.result.establishLatencyMsAvg === 0) {
|
||||
t.data.result.establishLatencyMs = t.data.result.establishLatencyMsAvg
|
||||
index = 0
|
||||
}
|
||||
if (t.data.result.httpResponseLatencyAvg || t.data.result.httpResponseLatencyAvg === 0) {
|
||||
t.data.result.httpResponseLatency = t.data.result.httpResponseLatencyAvg
|
||||
index = 1
|
||||
}
|
||||
if (t.data.result.tcpLostlenPercentAvg || t.data.result.tcpLostlenPercentAvg === 0) {
|
||||
t.data.result.tcpLostlenPercent = t.data.result.tcpLostlenPercentAvg
|
||||
index = 3
|
||||
}
|
||||
if (t.data.result.pktRetransPercentAvg || t.data.result.pktRetransPercentAvg === 0) {
|
||||
t.data.result.pktRetransPercent = t.data.result.pktRetransPercentAvg
|
||||
index = 4
|
||||
}
|
||||
if (t.data.result.sslConLatencyAvg || t.data.result.sslConLatencyAvg === 0) {
|
||||
t.data.result.sslConLatency = t.data.result.sslConLatencyAvg
|
||||
index = 2
|
||||
}
|
||||
scoreInfo[keyPre[index] + 'Score'] = computeScore(t.data.result, index)
|
||||
this.npmNetworkCycleData.push(t.data.result)
|
||||
const data = {
|
||||
establishLatencyMs: t.data.result.establishLatencyMsAvg,
|
||||
httpResponseLatency: t.data.result.httpResponseLatencyAvg,
|
||||
sslConLatency: t.data.result.sslConLatencyAvg,
|
||||
tcpLostlenPercent: t.data.result.tcpLostlenPercentAvg,
|
||||
pktRetransPercent: t.data.result.pktRetransPercentAvg
|
||||
}
|
||||
score = computeScore(data)
|
||||
}
|
||||
})
|
||||
scoreInfo.score = Math.ceil((scoreInfo.tcpScore + scoreInfo.httpScore + scoreInfo.sslScore + scoreInfo.tcpLostScore + scoreInfo.packetRetransScore) * 6)
|
||||
if (scoreInfo.score > 6) {
|
||||
scoreInfo.score = 6
|
||||
}
|
||||
this.$store.commit('setNpmThirdLevelMenuScore', scoreInfo.score)
|
||||
this.$store.commit('setNpmThirdLevelMenuScore', score)
|
||||
this.npmNetworkLastCycleQuery()
|
||||
}).catch(e => {
|
||||
this.toggleLoading(false)
|
||||
|
||||
Reference in New Issue
Block a user