parent
4b4055f71b
commit
8c3c19a40f
|
@ -405,15 +405,21 @@ public class ApiDefinitionExecResultService {
|
|||
if (startTime == null) {
|
||||
return new ArrayList<>(0);
|
||||
} else {
|
||||
List<ExecutedCaseInfoResult> list = extApiDefinitionExecResultMapper.findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(projectId, startTime.getTime());
|
||||
TreeMap<Long, ExecutedCaseInfoResult> treeMap = new TreeMap<>();
|
||||
|
||||
List<ExecutedCaseInfoResult> apiCaseList = extApiDefinitionExecResultMapper.findFaliureApiCaseInfoByProjectID(projectId, startTime.getTime(), limitNumber);
|
||||
List<ExecutedCaseInfoResult> scenarioCaseList = extApiDefinitionExecResultMapper.findFaliureScenarioInfoByProjectID(projectId, startTime.getTime(), limitNumber);
|
||||
apiCaseList.forEach(item -> {
|
||||
treeMap.put(item.getFailureTimes(), item);
|
||||
});
|
||||
scenarioCaseList.forEach(item -> {
|
||||
treeMap.put(item.getFailureTimes(), item);
|
||||
});
|
||||
|
||||
List<ExecutedCaseInfoResult> returnList = new ArrayList<>(limitNumber);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (i < limitNumber) {
|
||||
//开始遍历查询TestPlan信息 --> 提供前台做超链接
|
||||
ExecutedCaseInfoResult item = list.get(i);
|
||||
|
||||
NavigableMap<Long, ExecutedCaseInfoResult> descendingMap = treeMap.descendingMap();
|
||||
for (ExecutedCaseInfoResult item : descendingMap.values()) {
|
||||
if (returnList.size() <= 10) {
|
||||
QueryTestPlanRequest planRequest = new QueryTestPlanRequest();
|
||||
planRequest.setProjectId(projectId);
|
||||
if ("scenario".equals(item.getCaseType())) {
|
||||
|
|
|
@ -29,6 +29,10 @@ public interface ExtApiDefinitionExecResultMapper {
|
|||
|
||||
List<ExecutedCaseInfoResult> findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("startTimestamp") long startTimestamp);
|
||||
|
||||
List<ExecutedCaseInfoResult> findFaliureApiCaseInfoByProjectID(@Param("projectId") String projectId, @Param("startTimestamp") long startTimestamp, @Param("limitNumber") int limitNumber);
|
||||
|
||||
List<ExecutedCaseInfoResult> findFaliureScenarioInfoByProjectID(@Param("projectId") String projectId, @Param("startTimestamp") long startTimestamp, @Param("limitNumber") int limitNumber);
|
||||
|
||||
String selectExecResult(String resourceId);
|
||||
|
||||
ApiDefinitionExecResult selectPlanApiMaxResultByTestIdAndType(String resourceId, String type);
|
||||
|
|
|
@ -137,6 +137,64 @@
|
|||
) showTable
|
||||
ORDER BY showTable.failureTimes DESC
|
||||
</select>
|
||||
|
||||
<select id="findFaliureApiCaseInfoByProjectID"
|
||||
resultType="io.metersphere.api.dto.datacount.ExecutedCaseInfoResult">
|
||||
SELECT testCase.testCaseID AS testCaseID,
|
||||
testCase.id AS id,
|
||||
testCase.testCaseName AS caseName,
|
||||
testCase.testPlanName AS testPlan,
|
||||
caseErrorCountData.dataCountNumber AS failureTimes,
|
||||
'apiCase' AS caseType
|
||||
FROM (SELECT testPlanCase.id AS testPlanCaseID,
|
||||
testPlanCase.api_case_id as testCaseID,
|
||||
apiCase.id AS id,
|
||||
apiCase.`name` AS testCaseName,
|
||||
testPlan.`name` AS testPlanName,
|
||||
testPlanCase.update_time as updateTime
|
||||
FROM api_test_case apiCase
|
||||
inner join api_definition on api_definition.id = apiCase.api_definition_id
|
||||
INNER JOIN test_plan_api_case testPlanCase ON testPlanCase.api_case_id = apiCase.id
|
||||
INNER JOIN test_plan testPlan ON testPlan.id = testPlanCase.test_plan_id
|
||||
and api_definition.status != 'Trash'
|
||||
ORDER BY apiCase.create_time DESC) testCase
|
||||
INNER JOIN (SELECT resource_id AS testPlanCaseID,
|
||||
COUNT(id) AS dataCountNumber,
|
||||
start_time AS executeTime
|
||||
FROM api_definition_exec_result
|
||||
WHERE resource_id IN (SELECT t2.id
|
||||
FROM api_test_case t1
|
||||
INNER JOIN test_plan_api_case t2 ON t1.id = t2.api_case_id
|
||||
WHERE t1.project_id = #{projectId})
|
||||
and `status` = 'error'
|
||||
GROUP BY resource_id) caseErrorCountData
|
||||
ON caseErrorCountData.testPlanCaseID = testCase.testPlanCaseID
|
||||
WHERE testCase.updateTime >= #{startTimestamp}
|
||||
ORDER BY failureTimes DESC limit #{limitNumber}
|
||||
</select>
|
||||
|
||||
<select id="findFaliureScenarioInfoByProjectID"
|
||||
resultType="io.metersphere.api.dto.datacount.ExecutedCaseInfoResult">
|
||||
SELECT ac.id AS testCaseID,
|
||||
rp.id AS id,
|
||||
ac.NAME AS caseName,
|
||||
count(rp.id) AS failureTimes,
|
||||
'scenario' AS caseType
|
||||
FROM api_scenario_report rp
|
||||
INNER JOIN
|
||||
(
|
||||
SELECT scene.id, scene.`name`
|
||||
FROM api_scenario scene
|
||||
WHERE scene.project_id = #{projectId}
|
||||
AND scene.`status` != 'Trash'
|
||||
AND scene.id IN (SELECT api_scenario_id FROM test_plan_api_scenario WHERE test_plan_id IN (SELECT id FROM test_plan))
|
||||
) ac ON rp.md5_scenario_id = md5(ac.id)
|
||||
WHERE rp.STATUS = 'Error'
|
||||
AND rp.create_time > #{startTimestamp}
|
||||
GROUP BY rp.md5_scenario_id
|
||||
ORDER BY failureTimes DESC limit #{limitNumber}
|
||||
</select>
|
||||
|
||||
<select id="findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber"
|
||||
resultType="io.metersphere.api.dto.datacount.ExecutedCaseInfoResult">
|
||||
SELECT *
|
||||
|
|
Loading…
Reference in New Issue