fix(接口测试): 修复接口测试首页本周新建跳转错误的问题

--bug=1023817 --user=宋天阳 【接口测试】github#21926,本周新增接口统计数据,链接错误
https://www.tapd.cn/55049933/s/1348336
This commit is contained in:
song-tianyang 2023-03-10 19:22:18 +08:00 committed by 建国
parent 18fc1d3cc9
commit 1f5f32b71a
7 changed files with 44 additions and 36 deletions

View File

@ -15,7 +15,7 @@
</el-row> </el-row>
<el-row :gutter="16"> <el-row :gutter="16">
<el-col :span="12"> <el-col :span="12">
<api-dashboard :version-id="versionId" @redirectPage="redirectPage" ref="apiDashboard" /> <api-dashboard @redirectPage="redirectPage" ref="apiDashboard" />
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<api-case-dashboard @redirectPage="redirectPage" ref="apiCaseDashboard" /> <api-case-dashboard @redirectPage="redirectPage" ref="apiCaseDashboard" />

View File

@ -20,6 +20,7 @@ export default {
props: { props: {
apiData: Object, apiData: Object,
totalTime: Number, totalTime: Number,
versionId: String,
isExport: { isExport: {
type: Boolean, type: Boolean,
default: false, default: false,
@ -175,7 +176,7 @@ export default {
}, },
}, },
sublink: hasPermission('PROJECT_API_DEFINITION:READ') sublink: hasPermission('PROJECT_API_DEFINITION:READ')
? '/#/api/definition/' + getUUID() + '/api/thisWeekCount' ? '/#/api/definition/' + this.versionId + '/api/api/thisWeekCount'
: '', : '',
subtextStyle: { subtextStyle: {
color: '#1F2329', color: '#1F2329',

View File

@ -20,7 +20,7 @@
</div> </div>
<div v-show="!loadError"> <div v-show="!loadError">
<div class="main-info"> <div class="main-info">
<count-chart :api-data="apiData" ref="countChart" /> <count-chart :version-id="versionId" :api-data="apiData" ref="countChart" />
</div> </div>
<div class="addition-info"> <div class="addition-info">
<el-row :gutter="16" style="margin: 0"> <el-row :gutter="16" style="margin: 0">
@ -141,6 +141,7 @@ export default {
loadError: false, loadError: false,
apiCoveredRageToolTip: this.$t('api_test.home_page.formula.api_coverage'), apiCoveredRageToolTip: this.$t('api_test.home_page.formula.api_coverage'),
completedRageToolTip: this.$t('api_test.home_page.formula.completion'), completedRageToolTip: this.$t('api_test.home_page.formula.completion'),
versionId: 'default',
apiData: { apiData: {
httpCount: 0, httpCount: 0,
tcpCount: 0, tcpCount: 0,
@ -161,6 +162,7 @@ export default {
search(versionId) { search(versionId) {
this.loading = true; this.loading = true;
this.loadError = false; this.loadError = false;
this.versionId = versionId;
let selectProjectId = getCurrentProjectID(); let selectProjectId = getCurrentProjectID();
apiCountByProjectId(selectProjectId, versionId) apiCountByProjectId(selectProjectId, versionId)
.then((response) => { .then((response) => {

View File

@ -2,7 +2,6 @@ package io.metersphere.controller;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.TestCase; import io.metersphere.base.domain.TestCase;
import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.constants.MicroServiceName;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
@ -62,16 +61,24 @@ public class TrackController {
return statistics; return statistics;
} }
@GetMapping("/failure/case/about/plan/{projectId}/{versionId}/{limitNumber}/{goPage}/{pageSize}") @GetMapping("/failure/case/about/plan/{projectId}/{versionId}/{pageSize}/{goPage}")
public Pager<List<ExecutedCaseInfoDTO>> failureCaseAboutTestPlan(@PathVariable String projectId, @PathVariable String versionId, public Pager<List<ExecutedCaseInfoDTO>> 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")) { if (StringUtils.equalsIgnoreCase(versionId, "default")) {
versionId = null; versionId = null;
} }
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
List<ExecutedCaseInfoResult> selectDataList = trackService.findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(projectId, versionId, limitNumber); List<ExecutedCaseInfoResult> selectDataList = trackService.findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(projectId, versionId);
List<ExecutedCaseInfoDTO> returnList = this.getResultList(goPage, pageSize, selectDataList);
Page<Object> page = new Page<>(goPage, pageSize);
page.setTotal(selectDataList.size());
return PageUtils.setPageInfo(page, returnList);
}
private List<ExecutedCaseInfoDTO> getResultList(int goPage, int pageSize, List<ExecutedCaseInfoResult> selectDataList) {
List<ExecutedCaseInfoDTO> returnList = new ArrayList<>(selectDataList.size()); List<ExecutedCaseInfoDTO> returnList = new ArrayList<>(selectDataList.size());
for (int dataIndex = 0; dataIndex < selectDataList.size(); dataIndex++) { for (int dataIndex = goPage * pageSize; dataIndex < selectDataList.size(); dataIndex++) {
if (returnList.size() < pageSize) {
ExecutedCaseInfoDTO dataDTO = new ExecutedCaseInfoDTO(); ExecutedCaseInfoDTO dataDTO = new ExecutedCaseInfoDTO();
dataDTO.setSortIndex(dataIndex + 1); dataDTO.setSortIndex(dataIndex + 1);
ExecutedCaseInfoResult selectData = selectDataList.get(dataIndex); ExecutedCaseInfoResult selectData = selectDataList.get(dataIndex);
@ -85,8 +92,10 @@ public class TrackController {
dataDTO.setTestPlanDTOList(selectData.getTestPlanDTOList()); dataDTO.setTestPlanDTOList(selectData.getTestPlanDTOList());
returnList.add(dataDTO); returnList.add(dataDTO);
} }
return PageUtils.setPageInfo(page, returnList);
} }
return returnList;
}
@GetMapping("/relevance/count/{projectId}") @GetMapping("/relevance/count/{projectId}")
public TrackStatisticsDTO getRelevanceCount(@PathVariable String projectId) { public TrackStatisticsDTO getRelevanceCount(@PathVariable String projectId) {

View File

@ -308,7 +308,7 @@ public class TrackService {
return testPlan.getPassRate(); return testPlan.getPassRate();
} }
public List<ExecutedCaseInfoResult> findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(String projectId, String versionId, int limitNumber) { public List<ExecutedCaseInfoResult> findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(String projectId, String versionId) {
//获取7天之前的日期 //获取7天之前的日期
Date startDay = DateUtils.dateSum(new Date(), -6); Date startDay = DateUtils.dateSum(new Date(), -6);
@ -323,6 +323,7 @@ public class TrackService {
if (startTime == null) { if (startTime == null) {
return new ArrayList<>(0); return new ArrayList<>(0);
} else { } else {
int limitNumber = 10;
List<ExecutedCaseInfoResult> returnList = new ArrayList<>(limitNumber); List<ExecutedCaseInfoResult> returnList = new ArrayList<>(limitNumber);
ArrayList<ExecutedCaseInfoResult> allCaseExecList = new ArrayList<>(); ArrayList<ExecutedCaseInfoResult> allCaseExecList = new ArrayList<>();
allCaseExecList.addAll(extTestPlanTestCaseMapper.findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(projectId, versionId, startTime.getTime(), limitNumber)); allCaseExecList.addAll(extTestPlanTestCaseMapper.findFailureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(projectId, versionId, startTime.getTime(), limitNumber));

View File

@ -4,14 +4,9 @@ export function getTrackCount(selectProjectId) {
return get("/track/count/" + selectProjectId); return get("/track/count/" + selectProjectId);
} }
export function homeTestPlanFailureCaseGet( export function homeTestPlanFailureCaseGet(projectId, pageSize, currentPage) {
projectId,
limitNumber,
currentPage,
pageSize
) {
return get( return get(
`/track/failure/case/about/plan/${projectId}/default/${limitNumber}/${currentPage}/${pageSize}` `/track/failure/case/about/plan/${projectId}/default/${pageSize}/${currentPage}`
); );
} }

View File

@ -35,7 +35,7 @@
style="min-height: 228px" style="min-height: 228px"
> >
<el-table-column <el-table-column
type="index" prop="sortIndex"
:label="$t('home.case.index')" :label="$t('home.case.index')"
show-overflow-tooltip show-overflow-tooltip
width="100px" width="100px"
@ -131,6 +131,7 @@
:page-size.sync="pageSize" :page-size.sync="pageSize"
layout="prev, pager, next, sizes" layout="prev, pager, next, sizes"
:total="total" :total="total"
:pageSizes="[5, 10]"
/> />
</div> </div>
</div> </div>
@ -176,14 +177,13 @@ export default {
this.loadError = false; this.loadError = false;
homeTestPlanFailureCaseGet( homeTestPlanFailureCaseGet(
this.projectId, this.projectId,
10, this.pageSize,
this.currentPage, this.currentPage - 1
this.pageSize
) )
.then((r) => { .then((r) => {
this.loading = false; this.loading = false;
this.loadError = false; this.loadError = false;
this.total = r.data.itemCount; this.total = 10;
this.tableData = r.data.listObject; this.tableData = r.data.listObject;
}) })
.catch(() => { .catch(() => {