From 1f5f32b71a1888a722652033934a0c22fd37ffb8 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 10 Mar 2023 19:22:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E6=9C=AC=E5=91=A8=E6=96=B0=E5=BB=BA=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1023817 --user=宋天阳 【接口测试】github#21926,本周新增接口统计数据,链接错误 https://www.tapd.cn/55049933/s/1348336 --- .../frontend/src/business/home/ApiHome.vue | 2 +- .../home/components/chart/CountChart.vue | 3 +- .../components/dashboard/ApiDashboard.vue | 4 +- .../controller/TrackController.java | 49 +++++++++++-------- .../io/metersphere/service/TrackService.java | 3 +- test-track/frontend/src/api/track.js | 9 +--- .../home/components/FailureTestCaseList.vue | 10 ++-- 7 files changed, 44 insertions(+), 36 deletions(-) diff --git a/api-test/frontend/src/business/home/ApiHome.vue b/api-test/frontend/src/business/home/ApiHome.vue index af77ada71f..80b4d19d5a 100644 --- a/api-test/frontend/src/business/home/ApiHome.vue +++ b/api-test/frontend/src/business/home/ApiHome.vue @@ -15,7 +15,7 @@ - + diff --git a/api-test/frontend/src/business/home/components/chart/CountChart.vue b/api-test/frontend/src/business/home/components/chart/CountChart.vue index 1e5a682c56..ac8676613e 100644 --- a/api-test/frontend/src/business/home/components/chart/CountChart.vue +++ b/api-test/frontend/src/business/home/components/chart/CountChart.vue @@ -20,6 +20,7 @@ export default { props: { apiData: Object, totalTime: Number, + versionId: String, isExport: { type: Boolean, default: false, @@ -175,7 +176,7 @@ export default { }, }, sublink: hasPermission('PROJECT_API_DEFINITION:READ') - ? '/#/api/definition/' + getUUID() + '/api/thisWeekCount' + ? '/#/api/definition/' + this.versionId + '/api/api/thisWeekCount' : '', subtextStyle: { color: '#1F2329', diff --git a/api-test/frontend/src/business/home/components/dashboard/ApiDashboard.vue b/api-test/frontend/src/business/home/components/dashboard/ApiDashboard.vue index 78a4ebb110..356e0aff8b 100644 --- a/api-test/frontend/src/business/home/components/dashboard/ApiDashboard.vue +++ b/api-test/frontend/src/business/home/components/dashboard/ApiDashboard.vue @@ -20,7 +20,7 @@
- +
@@ -141,6 +141,7 @@ export default { loadError: false, apiCoveredRageToolTip: this.$t('api_test.home_page.formula.api_coverage'), completedRageToolTip: this.$t('api_test.home_page.formula.completion'), + versionId: 'default', apiData: { httpCount: 0, tcpCount: 0, @@ -161,6 +162,7 @@ export default { search(versionId) { this.loading = true; this.loadError = false; + this.versionId = versionId; let selectProjectId = getCurrentProjectID(); apiCountByProjectId(selectProjectId, versionId) .then((response) => { diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java b/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java index ff476d1175..84458995e2 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java @@ -2,7 +2,6 @@ package io.metersphere.controller; import com.github.pagehelper.Page; -import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.TestCase; import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.utils.PageUtils; @@ -62,32 +61,42 @@ public class TrackController { return statistics; } - @GetMapping("/failure/case/about/plan/{projectId}/{versionId}/{limitNumber}/{goPage}/{pageSize}") + @GetMapping("/failure/case/about/plan/{projectId}/{versionId}/{pageSize}/{goPage}") public Pager> failureCaseAboutTestPlan(@PathVariable String projectId, @PathVariable String versionId, - @PathVariable int limitNumber, @PathVariable int goPage, @PathVariable int pageSize) { + @PathVariable int pageSize, @PathVariable int goPage) { if (StringUtils.equalsIgnoreCase(versionId, "default")) { versionId = null; } - Page page = PageHelper.startPage(goPage, pageSize, true); - List selectDataList = trackService.findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(projectId, versionId, limitNumber); - List returnList = new ArrayList<>(selectDataList.size()); - for (int dataIndex = 0; dataIndex < selectDataList.size(); dataIndex++) { - ExecutedCaseInfoDTO dataDTO = new ExecutedCaseInfoDTO(); - dataDTO.setSortIndex(dataIndex + 1); - ExecutedCaseInfoResult selectData = selectDataList.get(dataIndex); - dataDTO.setCaseID(selectData.getTestCaseID()); - dataDTO.setCaseName(selectData.getCaseName()); - dataDTO.setTestPlan(selectData.getTestPlan()); - dataDTO.setFailureTimes(selectData.getFailureTimes()); - dataDTO.setTestPlanId(selectData.getTestPlanId()); - dataDTO.setCaseType(selectData.getCaseType()); - dataDTO.setId(selectData.getId()); - dataDTO.setTestPlanDTOList(selectData.getTestPlanDTOList()); - returnList.add(dataDTO); - } + + List selectDataList = trackService.findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(projectId, versionId); + List returnList = this.getResultList(goPage, pageSize, selectDataList); + Page page = new Page<>(goPage, pageSize); + page.setTotal(selectDataList.size()); return PageUtils.setPageInfo(page, returnList); } + private List getResultList(int goPage, int pageSize, List selectDataList) { + List returnList = new ArrayList<>(selectDataList.size()); + for (int dataIndex = goPage * pageSize; dataIndex < selectDataList.size(); dataIndex++) { + if (returnList.size() < pageSize) { + ExecutedCaseInfoDTO dataDTO = new ExecutedCaseInfoDTO(); + dataDTO.setSortIndex(dataIndex + 1); + ExecutedCaseInfoResult selectData = selectDataList.get(dataIndex); + dataDTO.setCaseID(selectData.getTestCaseID()); + dataDTO.setCaseName(selectData.getCaseName()); + dataDTO.setTestPlan(selectData.getTestPlan()); + dataDTO.setFailureTimes(selectData.getFailureTimes()); + dataDTO.setTestPlanId(selectData.getTestPlanId()); + dataDTO.setCaseType(selectData.getCaseType()); + dataDTO.setId(selectData.getId()); + dataDTO.setTestPlanDTOList(selectData.getTestPlanDTOList()); + returnList.add(dataDTO); + } + } + return returnList; + } + + @GetMapping("/relevance/count/{projectId}") public TrackStatisticsDTO getRelevanceCount(@PathVariable String projectId) { TrackStatisticsDTO statistics = new TrackStatisticsDTO(); diff --git a/test-track/backend/src/main/java/io/metersphere/service/TrackService.java b/test-track/backend/src/main/java/io/metersphere/service/TrackService.java index ad1f746c1f..a4e1c5e0d9 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TrackService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TrackService.java @@ -308,7 +308,7 @@ public class TrackService { return testPlan.getPassRate(); } - public List findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(String projectId, String versionId, int limitNumber) { + public List findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(String projectId, String versionId) { //获取7天之前的日期 Date startDay = DateUtils.dateSum(new Date(), -6); @@ -323,6 +323,7 @@ public class TrackService { if (startTime == null) { return new ArrayList<>(0); } else { + int limitNumber = 10; List returnList = new ArrayList<>(limitNumber); ArrayList allCaseExecList = new ArrayList<>(); allCaseExecList.addAll(extTestPlanTestCaseMapper.findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(projectId, versionId, startTime.getTime(), limitNumber)); diff --git a/test-track/frontend/src/api/track.js b/test-track/frontend/src/api/track.js index 6e67c1b389..f3a9a7af74 100644 --- a/test-track/frontend/src/api/track.js +++ b/test-track/frontend/src/api/track.js @@ -4,14 +4,9 @@ export function getTrackCount(selectProjectId) { return get("/track/count/" + selectProjectId); } -export function homeTestPlanFailureCaseGet( - projectId, - limitNumber, - currentPage, - pageSize -) { +export function homeTestPlanFailureCaseGet(projectId, pageSize, currentPage) { return get( - `/track/failure/case/about/plan/${projectId}/default/${limitNumber}/${currentPage}/${pageSize}` + `/track/failure/case/about/plan/${projectId}/default/${pageSize}/${currentPage}` ); } diff --git a/test-track/frontend/src/business/home/components/FailureTestCaseList.vue b/test-track/frontend/src/business/home/components/FailureTestCaseList.vue index 31b4bf8768..95a0344301 100644 --- a/test-track/frontend/src/business/home/components/FailureTestCaseList.vue +++ b/test-track/frontend/src/business/home/components/FailureTestCaseList.vue @@ -35,7 +35,7 @@ style="min-height: 228px" > @@ -176,14 +177,13 @@ export default { this.loadError = false; homeTestPlanFailureCaseGet( this.projectId, - 10, - this.currentPage, - this.pageSize + this.pageSize, + this.currentPage - 1 ) .then((r) => { this.loading = false; this.loadError = false; - this.total = r.data.itemCount; + this.total = 10; this.tableData = r.data.listObject; }) .catch(() => {