fix(接口测试): 修复用例报告结束时间排序错误问题
--bug=1012783 --user=赵勇 【接口测试】接口测试-测试报告,case报告,结束时间排序只排了当前页面的数据 https://www.tapd.cn/55049933/s/1169003
This commit is contained in:
parent
d21f56f779
commit
b1027a3e72
|
@ -407,7 +407,7 @@ public class APITestController {
|
|||
public Pager<List<ApiDefinitionExecResultExpand>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryAPIReportRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
request.setLimit("LIMIT " + (goPage - 1) * pageSize + "," + pageSize * 50);
|
||||
return PageUtils.setPageInfo(page, apiDefinitionExecResultService.exceReportlist(request));
|
||||
return PageUtils.setPageInfo(page, apiDefinitionExecResultService.apiReportList(request));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
|||
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
|
||||
import io.metersphere.commons.constants.*;
|
||||
import io.metersphere.commons.utils.*;
|
||||
import io.metersphere.controller.request.OrderRequest;
|
||||
import io.metersphere.dto.RequestResult;
|
||||
import io.metersphere.dto.ResultDTO;
|
||||
import io.metersphere.notice.sender.NoticeModel;
|
||||
|
@ -455,7 +456,9 @@ public class ApiDefinitionExecResultService {
|
|||
saveResult.setStatus(status);
|
||||
saveResult.setStartTime(item.getStartTime());
|
||||
saveResult.setEndTime(item.getEndTime());
|
||||
|
||||
if (item.getStartTime() >= item.getEndTime()) {
|
||||
saveResult.setEndTime(System.currentTimeMillis());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(saveResult.getTriggerMode()) && saveResult.getTriggerMode().equals("CASE")) {
|
||||
saveResult.setTriggerMode(TriggerMode.MANUAL.name());
|
||||
}
|
||||
|
@ -495,8 +498,23 @@ public class ApiDefinitionExecResultService {
|
|||
return extApiDefinitionExecResultMapper.selectForPlanReport(apiReportIds);
|
||||
}
|
||||
|
||||
public List<ApiDefinitionExecResultExpand> exceReportlist(QueryAPIReportRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
private static List<OrderRequest> getDefaultOrderByField(String prefix, List<OrderRequest> orders, String field) {
|
||||
if (orders == null || orders.size() < 1) {
|
||||
OrderRequest orderRequest = new OrderRequest();
|
||||
orderRequest.setName(field);
|
||||
orderRequest.setType("desc");
|
||||
if (StringUtils.isNotBlank(prefix)) {
|
||||
orderRequest.setPrefix(prefix);
|
||||
}
|
||||
orders = new ArrayList<>();
|
||||
orders.add(orderRequest);
|
||||
return orders;
|
||||
}
|
||||
return orders;
|
||||
}
|
||||
|
||||
public List<ApiDefinitionExecResultExpand> apiReportList(QueryAPIReportRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders(), "end_time"));
|
||||
List<ApiDefinitionExecResultExpand> list = extApiDefinitionExecResultMapper.list(request);
|
||||
List<String> userIds = list.stream().map(ApiDefinitionExecResult::getUserId)
|
||||
.collect(Collectors.toList());
|
||||
|
|
|
@ -124,13 +124,12 @@
|
|||
</select>
|
||||
<select id="list" resultType="io.metersphere.base.domain.ApiDefinitionExecResultExpand">
|
||||
SELECT a_r.name AS test_name,
|
||||
if (a_r.end_time + 0 > a_r.create_time + 0, a_r.end_time, a_r.create_time) as end_time,
|
||||
a_r.end_time,
|
||||
a_r.user_id,
|
||||
a_r.name,
|
||||
a_r.id,
|
||||
a_r.project_id,
|
||||
a_r.create_time as create_time,
|
||||
a_r.create_time as update_time,
|
||||
a_r.create_time,
|
||||
a_r.status,
|
||||
a_r.trigger_mode,
|
||||
a_r.report_type,
|
||||
|
|
|
@ -34,6 +34,10 @@ public class ServiceUtils {
|
|||
return getDefaultOrder(null, orders);
|
||||
}
|
||||
|
||||
public static List<OrderRequest> getDefaultOrder(List<OrderRequest> orders, String field) {
|
||||
return getDefaultOrder(null, field, orders);
|
||||
}
|
||||
|
||||
public static List<OrderRequest> getDefaultSortOrder(List<OrderRequest> orders) {
|
||||
return getDefaultOrderByField(null, orders, "order");
|
||||
}
|
||||
|
@ -46,6 +50,10 @@ public class ServiceUtils {
|
|||
return getDefaultOrderByField(prefix, orders, "update_time");
|
||||
}
|
||||
|
||||
public static List<OrderRequest> getDefaultOrder(String prefix, String field, List<OrderRequest> orders) {
|
||||
return getDefaultOrderByField(prefix, orders, field);
|
||||
}
|
||||
|
||||
private static List<OrderRequest> getDefaultOrderByField(String prefix, List<OrderRequest> orders, String field) {
|
||||
if (orders == null || orders.size() < 1) {
|
||||
OrderRequest orderRequest = new OrderRequest();
|
||||
|
@ -129,6 +137,7 @@ public class ServiceUtils {
|
|||
|
||||
/**
|
||||
* 初始化 order 列
|
||||
*
|
||||
* @param clazz
|
||||
* @param mapClazz
|
||||
* @param selectProjectIdsFunc
|
||||
|
@ -137,8 +146,8 @@ public class ServiceUtils {
|
|||
* @param <M>
|
||||
*/
|
||||
public static <T, M> void initOrderField(Class<T> clazz, Class<M> mapClazz,
|
||||
Supplier<List<String>> selectProjectIdsFunc,
|
||||
Function<String, List<String>> getIdsOrderByUpdateTimeFunc) {
|
||||
Supplier<List<String>> selectProjectIdsFunc,
|
||||
Function<String, List<String>> getIdsOrderByUpdateTimeFunc) {
|
||||
|
||||
try {
|
||||
|
||||
|
@ -172,7 +181,6 @@ public class ServiceUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param request
|
||||
* @param clazz
|
||||
* @param selectByPrimaryKeyFunc
|
||||
|
@ -182,10 +190,10 @@ public class ServiceUtils {
|
|||
* @param <T>
|
||||
*/
|
||||
public static <T> void updateOrderField(ResetOrderRequest request, Class<T> clazz,
|
||||
Function<String, T> selectByPrimaryKeyFunc,
|
||||
BiFunction<String, Long, Long> getPreOrderFunc,
|
||||
BiFunction<String, Long, Long> getLastOrderFunc,
|
||||
Consumer<T> updateByPrimaryKeySelectiveFuc) {
|
||||
Function<String, T> selectByPrimaryKeyFunc,
|
||||
BiFunction<String, Long, Long> getPreOrderFunc,
|
||||
BiFunction<String, Long, Long> getLastOrderFunc,
|
||||
Consumer<T> updateByPrimaryKeySelectiveFuc) {
|
||||
Long order;
|
||||
Long lastOrPreOrder;
|
||||
try {
|
||||
|
@ -226,13 +234,14 @@ public class ServiceUtils {
|
|||
|
||||
/**
|
||||
* 创建时获取下一个 order 值
|
||||
*
|
||||
* @param groupId
|
||||
* @param getLastOrderFunc
|
||||
* @return
|
||||
*/
|
||||
public static Long getNextOrder(String groupId, BiFunction<String, Long, Long> getLastOrderFunc) {
|
||||
Long lastOrder = getLastOrderFunc.apply(groupId, null);
|
||||
return (lastOrder == null ? 0 : lastOrder) + ServiceUtils.ORDER_STEP;
|
||||
return (lastOrder == null ? 0 : lastOrder) + ServiceUtils.ORDER_STEP;
|
||||
}
|
||||
|
||||
public static <T> int getNextNum(String projectId, Class<T> clazz, Function<String, T> getNextNumFunc) {
|
||||
|
@ -242,7 +251,7 @@ public class ServiceUtils {
|
|||
if (data == null || getNum.invoke(data) == null) {
|
||||
return 100001;
|
||||
} else {
|
||||
return Optional.ofNullable((Integer)getNum.invoke(data) + 1).orElse(100001);
|
||||
return Optional.ofNullable((Integer) getNum.invoke(data) + 1).orElse(100001);
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -98,12 +98,7 @@
|
|||
</el-table-column>
|
||||
<el-table-column prop="endTime" min-width="120" :label="$t('report.test_end_time')" sortable>
|
||||
<template v-slot:default="scope">
|
||||
<span v-if="scope.row.endTime < scope.row.createTime">
|
||||
{{ scope.row.updateTime | timestampFormatDate }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ scope.row.endTime | timestampFormatDate }}
|
||||
</span>
|
||||
{{ scope.row.endTime | timestampFormatDate }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="triggerMode" width="150" :label="$t('commons.trigger_mode.name')"
|
||||
|
@ -142,7 +137,6 @@
|
|||
</ms-main-container>
|
||||
</ms-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getCurrentProjectID} from "@/common/js/utils";
|
||||
import {REPORT_CASE_CONFIGS, REPORT_CONFIGS} from "../../../common/components/search/search-components";
|
||||
|
|
|
@ -533,7 +533,7 @@ export default {
|
|||
// 场景变量
|
||||
let variables = [];
|
||||
if(this.currentScenario && this.currentScenario.variables) {
|
||||
JSON.parse(JSON.stringify(this.currentScenario.variables));
|
||||
variables = JSON.parse(JSON.stringify(this.currentScenario.variables));
|
||||
}
|
||||
let debugData = {
|
||||
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
|
||||
|
|
Loading…
Reference in New Issue