diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index f6c013ca51..f60a1e1fec 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -410,23 +410,28 @@ public class ApiDefinitionExecResultService { List apiCaseList = extApiDefinitionExecResultMapper.findFaliureApiCaseInfoByProjectID(projectId, startTime.getTime(), limitNumber); List scenarioCaseList = extApiDefinitionExecResultMapper.findFaliureScenarioInfoByProjectID(projectId, startTime.getTime(), limitNumber); apiCaseList.forEach(item -> { - if(treeMap.containsKey(item.getFailureTimes())){ - treeMap.get(item.getFailureTimes()).add(item); - }else { - treeMap.put(item.getFailureTimes(),new ArrayList<>(){{this.add(item);}}); + if (treeMap.containsKey(item.getFailureTimes())) { + treeMap.get(item.getFailureTimes()).add(item); + } else { + treeMap.put(item.getFailureTimes(), new ArrayList<>() {{ + this.add(item); + }}); } }); scenarioCaseList.forEach(item -> { - if(treeMap.containsKey(item.getFailureTimes())){ + if (treeMap.containsKey(item.getFailureTimes())) { treeMap.get(item.getFailureTimes()).add(item); - }else { - treeMap.put(item.getFailureTimes(),new ArrayList<>(){{this.add(item);}}); + } else { + treeMap.put(item.getFailureTimes(), new ArrayList<>() {{ + this.add(item); + }}); } }); List returnList = new ArrayList<>(limitNumber); NavigableMap> descendingMap = treeMap.descendingMap(); - caseInfoListforeach:for (List itemList : descendingMap.values()) { + caseInfoListforeach: + for (List itemList : descendingMap.values()) { for (ExecutedCaseInfoResult item : itemList) { if (returnList.size() <= 10) { QueryTestPlanRequest planRequest = new QueryTestPlanRequest(); @@ -531,6 +536,7 @@ public class ApiDefinitionExecResultService { public List apiReportList(QueryAPIReportRequest request) { request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders(), "end_time")); + this.initReportRequest(request); List list = extApiDefinitionExecResultMapper.list(request); List userIds = list.stream().map(ApiDefinitionExecResult::getUserId) .collect(Collectors.toList()); @@ -542,4 +548,20 @@ public class ApiDefinitionExecResultService { }); return list; } + + private void initReportRequest(QueryAPIReportRequest request) { + if (request != null) { + if (MapUtils.isNotEmpty(request.getFilters()) && request.getFilters().containsKey("trigger_mode")) { + boolean filterHasApi = false; + for (String triggerMode : request.getFilters().get("trigger_mode")) { + if (StringUtils.equalsIgnoreCase(triggerMode, "api")) { + filterHasApi = true; + } + } + if (filterHasApi) { + request.getFilters().get("trigger_mode").add("JENKINS"); + } + } + } + } } diff --git a/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue b/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue index 45ec0f71d8..a8bf3cc27b 100644 --- a/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue +++ b/frontend/src/business/components/common/tableItem/ReportTriggerModeItem.vue @@ -1,21 +1,22 @@