fix(接口定义): 用例状态统计不准确问题修复
This commit is contained in:
parent
0f8cefffb3
commit
67635aebbd
|
@ -7,7 +7,9 @@ import lombok.Setter;
|
|||
@Setter
|
||||
public class ApiComputeResult {
|
||||
private String apiDefinitionId;
|
||||
private String caseTotal;
|
||||
private int caseTotal;
|
||||
private String status;
|
||||
private String passRate;
|
||||
private int success;
|
||||
private int error;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class ApiDefinitionService {
|
|||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
public List<ApiDefinitionResult> list(ApiDefinitionRequest request) {
|
||||
request = this.initRequest(request,true,true);
|
||||
request = this.initRequest(request, true, true);
|
||||
List<ApiDefinitionResult> resList = extApiDefinitionMapper.list(request);
|
||||
calculateResult(resList);
|
||||
return resList;
|
||||
|
@ -87,16 +87,17 @@ public class ApiDefinitionService {
|
|||
|
||||
/**
|
||||
* 初始化部分参数
|
||||
*
|
||||
* @param request
|
||||
* @param setDefultOrders
|
||||
* @param checkThisWeekData
|
||||
* @return
|
||||
*/
|
||||
private ApiDefinitionRequest initRequest(ApiDefinitionRequest request,boolean setDefultOrders, boolean checkThisWeekData) {
|
||||
if(setDefultOrders){
|
||||
private ApiDefinitionRequest initRequest(ApiDefinitionRequest request, boolean setDefultOrders, boolean checkThisWeekData) {
|
||||
if (setDefultOrders) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
}
|
||||
if(checkThisWeekData){
|
||||
if (checkThisWeekData) {
|
||||
if (request.isSelectThisWeedData()) {
|
||||
Map<String, Date> weekFirstTimeAndLastTime = DateUtils.getWeedFirstTimeAndLastTime(new Date());
|
||||
Date weekFirstTime = weekFirstTimeAndLastTime.get("firstTime");
|
||||
|
@ -568,9 +569,16 @@ public class ApiDefinitionService {
|
|||
for (ApiDefinitionResult res : resList) {
|
||||
ApiComputeResult compRes = resultMap.get(res.getId());
|
||||
if (compRes != null) {
|
||||
res.setCaseTotal(compRes.getCaseTotal());
|
||||
res.setCaseTotal(String.valueOf(compRes.getCaseTotal()));
|
||||
res.setCasePassingRate(compRes.getPassRate());
|
||||
res.setCaseStatus(compRes.getStatus());
|
||||
// 状态优先级 未执行,未通过,通过
|
||||
if ((compRes.getError() + compRes.getSuccess()) < compRes.getCaseTotal()) {
|
||||
res.setCaseStatus("未执行");
|
||||
} else if (compRes.getError() > 0) {
|
||||
res.setCaseStatus("未通过");
|
||||
} else {
|
||||
res.setCaseStatus("通过");
|
||||
}
|
||||
} else {
|
||||
res.setCaseTotal("-");
|
||||
res.setCasePassingRate("-");
|
||||
|
|
|
@ -89,10 +89,11 @@
|
|||
|
||||
<select id="selectByIds" resultType="io.metersphere.api.dto.definition.ApiComputeResult">
|
||||
SELECT t1.api_definition_id apiDefinitionId,count(t1.id) caseTotal,
|
||||
CASE t2.STATUS WHEN 'success' THEN '通过' WHEN 'error' THEN '未通过' ELSE '未执行' END AS STATUS,CONCAT(FORMAT(SUM(IF (t2.`status`='success',1,0))/COUNT(t1.id)*100,2),'%') passRate
|
||||
SUM(case when t2.status ='success' then 1 else 0 end) as success ,SUM(case when t2.status ='error' then 1 else 0 end) as error,
|
||||
CONCAT(FORMAT(SUM(IF (t2.`status`='success',1,0))/COUNT(t1.id)*100,2),'%') passRate
|
||||
FROM api_test_case t1
|
||||
LEFT JOIN api_definition_exec_result t2 ON t1.last_result_id=t2.id
|
||||
group by t1.api_definition_id having t1.api_definition_id in
|
||||
LEFT JOIN api_definition_exec_result t2 ON t1.last_result_id=t2.id
|
||||
group by t1.api_definition_id having t1.api_definition_id in
|
||||
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
|
|
|
@ -233,6 +233,7 @@
|
|||
row.updateTime = data.updateTime;
|
||||
if (!row.message) {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.$emit('refresh');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -159,7 +159,7 @@
|
|||
})
|
||||
}
|
||||
this.$success(this.$t('schedule.event_success'));
|
||||
this.getApiTest();
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
refresh() {
|
||||
|
|
Loading…
Reference in New Issue