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