From 74de0c09ac00890f9eef6eb208bc557d51867ca8 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 14 Dec 2021 17:27:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8=E5=8C=96=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E6=80=BB=E6=97=B6=E9=97=B4=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1008828 --user=王孝刚 接口自动化报告总时间计算错误 https://www.tapd.cn/55049933/s/1080731 --- .../api/automation/report/ApiReportDetail.vue | 10 ++++++---- .../automation/report/SysnApiReportDetail.vue | 13 +++++++------ .../automation/report/components/MetricChart.vue | 16 +++++++--------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue index 6eae8054ab..c79a39a221 100644 --- a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue @@ -360,20 +360,22 @@ export default { }, computeTotalTime() { if (this.content.scenarios) { - let startTime = 99991611737506593; + let startTime = 0; let endTime = 0; + let requestTime = 0; this.content.scenarios.forEach((scenario) => { scenario.requestResults.forEach((request) => { - if (request.startTime && Number(request.startTime) < startTime) { + if (request.startTime && Number(request.startTime)) { startTime = request.startTime; } - if (request.endTime && Number(request.endTime) > endTime) { + if (request.endTime && Number(request.endTime)) { endTime = request.endTime; } + requestTime = requestTime + (endTime - startTime); }) }) if (startTime < endTime) { - this.totalTime = endTime - startTime + 100; + this.totalTime = requestTime } } }, diff --git a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue index c2ec7beb30..016affa43f 100644 --- a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue @@ -300,8 +300,9 @@ export default { }, formatResult(res) { let resMap = new Map; - this.startTime = 99991611737506593; + this.startTime = 0; this.endTime = 0; + let requestTime = 0; this.clearDebug(); if (res && res.scenarios) { res.scenarios.forEach(item => { @@ -330,20 +331,20 @@ export default { } else { this.reqError++; } - if (req.startTime && Number(req.startTime) < this.startTime) { + if (req.startTime && Number(req.startTime)) { this.startTime = req.startTime; } - if (req.endTime && Number(req.endTime) > this.endTime) { + if (req.endTime && Number(req.endTime)) { this.endTime = req.endTime; } + requestTime = requestTime + (this.endTime - this.startTime) } } } }) } - if (this.startTime < this.endTime) { - this.totalTime = this.endTime - this.startTime + 100; - } + this.totalTime = requestTime; + this.debugResult = resMap; this.setTreeValue(this.fullTreeNodes); this.reload(); diff --git a/frontend/src/business/components/api/automation/report/components/MetricChart.vue b/frontend/src/business/components/api/automation/report/components/MetricChart.vue index bd17bc1e32..e5d83cb300 100644 --- a/frontend/src/business/components/api/automation/report/components/MetricChart.vue +++ b/frontend/src/business/components/api/automation/report/components/MetricChart.vue @@ -134,17 +134,16 @@ }, methods: { initTime() { - this.time = this.totalTime - this.seconds = Math.floor(this.time / 1000) + this.time = this.totalTime; + this.seconds = (this.time) / 1000; if (this.seconds >= 1) { - if (this.seconds > 60) { - this.minutes = Math.round(this.time / 60) - this.seconds = Math.round(this.time % 60) - this.time = this.minutes + "min" + this.seconds + "s" + if (this.seconds < 60) { + this.seconds = Math.round(this.seconds * 100 / 1) / 100; + this.time = this.seconds + "s" } if (this.seconds > 60) { - this.minutes = Math.round(this.time / 60) - this.seconds = Math.round(this.time % 60) + this.minutes = Math.round(this.seconds / 60) + this.seconds = Math.round(this.seconds * 100 % 60) / 100; this.time = this.minutes + "min" + this.seconds + "s" } if (this.minutes > 60) { @@ -153,7 +152,6 @@ this.time = this.hour + "hour" + this.minutes + "min" + this.seconds + "s" } - this.time = (this.seconds) + "s" } else { this.time = this.totalTime + "ms" }